Skip to content

Commit 2f5fb77

Browse files
authored
Merge pull request #2 from madmax983/Rewrite
Rewrite
2 parents bf9ca0f + b73fe01 commit 2f5fb77

File tree

154 files changed

+1662
-3152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+1662
-3152
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ build.properties
1010
#node_modules
1111
node_modules/
1212
jsforce.config.json
13+
14+
#sfdx
15+
.sfdx/*

.travis.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
sudo: true
2+
dist: trusty
3+
cache: false
4+
addons:
5+
apt:
6+
sources:
7+
- google-chrome
8+
packages:
9+
- google-chrome-stable
10+
env:
11+
- URL=https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz
12+
before_install:
13+
- openssl aes-256-cbc -K $encrypted_bc21448d0b37_key -iv $encrypted_bc21448d0b37_iv
14+
-in assets/server.key.enc -out assets/server.key -d
15+
- export SFDX_AUTOUPDATE_DISABLE=true
16+
- export SFDX_USE_GENERIC_UNIX_KEYCHAIN=true
17+
- export SFDX_DOMAIN_RETRY=300
18+
- wget -qO- $URL | tar xJf -
19+
- export DISPLAY=:99.0
20+
- sh -e /etc/init.d/xvfb start
21+
- ./sfdx/install
22+
- export PATH=./sfdx/$(pwd):$PATH
23+
- sfdx plugins:install salesforcedx@pre-release
24+
- sfdx force:auth:jwt:grant --clientid $CONSUMERKEY --jwtkeyfile assets/server.key
25+
--username $USERNAME --setdefaultdevhubusername -a HubOrg
26+
script:
27+
- sfdx force:org:create -v HubOrg -s -f config/project-scratch-def.json -a ciorg
28+
- sfdx force:source:push -u ciorg
29+
- sfdx force:apex:test:run -u ciorg -c -r human
30+
- sfdx force:lightning:test:run -u ciorg
31+
- sfdx force:org:delete -u ciorg -p

README.md

Lines changed: 26 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,42 @@
1+
# Lightning-Redux [![Build Status](https://travis-ci.org/madmax983/lightning-redux.svg?branch=master)](https://travis-ci.org/madmax983/lightning-redux)
12

2-
# lightning-redux
3-
Lightning bindings for Redux
3+
## Usage
4+
The new version of Lightning-Redux simplifies the previous iteration down to a single Redux component. It serves as a wrapper around Redux itself, along with a few helper methods specific to Lightning.
45

5-
#Installation instructions:
6+
### Component Methods
7+
####
8+
##### createStore(name, reducer, initialState, middleware): create the Redux store.
69

7-
Simple Setup: Deploy the components to a Dev org.
10+
name: The name of the slice of state for the reducer creating the store.
811

9-
<a href="https://githubsfdeploy.herokuapp.com">
10-
<img alt="Deploy to Salesforce" src="https://raw.githubusercontent.com/afawcett/githubsfdeploy/master/deploy.png">
11-
</a>
12+
reducer: Initial root reducer
1213

13-
Advanced Setup:
14+
initialState: You can specify an initial shape to your store's shape.
1415

15-
1. Clone repo
16-
2. Copy jsforce.config.editme.json and create jsforce.config.json.
17-
3. Enter target Salesforce org credentials.
18-
4. Install [npm](https://www.npmjs.com/) if you don't already have it.
19-
5. Run npm install on directory
16+
middleware: You can include redux middleware like redux-thunk here. Lightning-Redux automatically wraps this with Redux compose.
2017

21-
#Gulp Targets
18+
##### dispatch(action): Works like you would expect. Dispatches the action to the Redux store. Fun fact: connect also sets a dispatch expando on the connected component for convenience.
2219

23-
There are a few gulp targets available. Running gulp 'target' will deploy the components to the Salesforce Org in jsforce.config.json
20+
##### subscribe(listener): This shouldn't be needed to be implemented, but is provided in case you want to write a custom connect method. The listener callback will be called on store updates.
2421

25-
deploy:base - the base Lightning-Redux bindings. These are all the component you need to use Redux in Lightning (plus redux.
26-
I am keeping a copy of Redux in the addons folder for convenience, but ideally you'll want to be installing
27-
it as a static resource with a fresh version).
22+
##### replaceReducer(nextReducer): Wraps Redux's replaceReducer function. Replaces the reducer function in the redux store.
2823

29-
deploy:addons - utility components and events to assist you in using Redux and Lightning Components together.
24+
##### registerReducer(name, reducer): Adds the specified reducer function to the redux store with the specificed name as it's slice of state.
3025

31-
deploy:SimpleCounter - deploy the SimpleCounter example
26+
##### connect(mapStateToAttributes, target): mapStateToAttributes is a key pair object where the key is the attribute on the component you want set, and the value is either the value in the redux state graph, or a callback function. This function receives the component and state to compute the value. You can pass the component you want connected, but if it isn't populated, it will get populated by event.getSource(). It also sets a dispatch expando for convenience in the component's controller methods.
3227

33-
deploy:ComplexCounter - deploy the ComplexCounter example
28+
##### getState: Technically not a component method, this is a convenience expando that allows access to the Redux state.
3429

35-
deploy:todo - deploy the todo example.
36-
37-
deploy:webpackTodo - deploy the webpackTodo example.
30+
## Installation
31+
Lightning-Redux Unmanaged Packaged (Redux Component, redux and redux-thunk static resource): https://login.salesforce.com/packaging/installPackage.apexp?p0=04t50000000M7PT
32+
Lightning-Redux-Examples (Counter and Todo Examples unmanaged package): https://login.salesforce.com/packaging/installPackage.apexp?p0=04t50000000M7Pi
3833

39-
deploy:examples - deploy all of the examples
34+
Otherwise, you can use the SFDX CLI to convert the source and do a metadata deploy.
4035

41-
deploy:kitchensink - DEPLOY ALL THE THINGS!
36+
## Resources
37+
Redux Documentation: http://redux.js.org/
38+
Awesome Redux: https://github.com/xgrommx/awesome-redux
39+
Lightning Components Developer Guide: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/intro_framework.htm
40+
Awesome Lightning: https://github.com/mailtoharshit/awesome-lighting
41+
Awesome Salesforce: https://github.com/mailtoharshit/awesome-salesforce
4242

43-
After deploying, you will want to create a Preview style app to plunk the components in to see them.
44-
Or take that Todo example, implement flexipage:availableForAllPageTypes", and plunk it down on your Lightning Experience homepage.
45-
46-
#Lightning-Redux Bindings
47-
You can just import Redux into a Lightning component and start using it right now as demonstrated in the SimpleCounter example.
48-
However, a few binding components are provided here to assist you in architecting a Lightning-Redux app.
49-
The base components are the Provider component, and a handful of events: reduxStoreChange, storeInitialized, and dispatchAction.
50-
51-
In addition, there a number of utility components provided in the addons folder. These are demonstrated in the todoApp example, but as the webpackTodo example shows, they are not necessary.
52-
53-
#Base Components
54-
##Provider
55-
The main interface between Redux and your Lightning Components. The Redux Store is kept inside a store aura:attribute with a type of "Object".
56-
You can either set the store directly via some bundled javascript file in the app level container, or pass the store in via the storeInitialized Event.
57-
Either way you will want to make sure to fire the storeInitialized event to bootstrap the provider.
58-
The provider emits reduxStoreChange events whenever there is a change in the store. Write handlers in your components to react to these changes, and make appropriate changes.
59-
It also handles a dispatchAction event. The payload that lightning event is an Action, and the handler for this event will dispatch the action on the store in the Provider.
60-
61-
##storeIntitialized Event
62-
Has a store param for sending the store to be set in the Provider.
63-
Also useful to write handlers on the other components when you want to have an action fire when the Provider first starts up(i.e. retrieving a list of SObjects from the DB)
64-
65-
##reduxStoreChange Event
66-
This event is fired by the Provider whenever there is a change in the store. Write handlers on components that you want to react to changes in the store.
67-
68-
##dispatchAction Event
69-
Lightning components can register and fire this event to send actions to be dispatched by the store in the Provider.
70-
The use of this component can be eliminated by using the bindActionCreators utility method from Redux, as demonstrated in the webpackTodo example.
71-
72-
#Addon Components
73-
##Reducer
74-
An abstract component that needs to be extended by a concrete component in order to function. Implement your reducers in these concrete components.
75-
Setting the name attribute in your concrete implementation will determine the name of the key in Redux store graph.
76-
77-
##RootReducer
78-
The RootReducer will take all the concrete Reducer components you write inside of it's {!v.body} and combine them with the combineReducers function from Redux.
79-
It will then emit a ReducersCombined event with this combined Reducer to be handled either by the top level app component, or a store component so that the store can be created.
80-
See the todoStore in the todoApp example for a demonstration.
81-
82-
#Using a bundling library like Webpack or Browserify
83-
This is the best way to go, but can be a little daunting for beginners.
84-
You can find a lot of great info at [Awesome Webpack](https://github.com/d3viant0ne/awesome-webpack), [Browserify Articles](http://browserify.org/articles.html)
85-
The webpackTodo example included in this repo should also give you a good idea of how to get started. The basic idea is to write all your javascript files the module import syntax you feel comfortable with.
86-
Then webpack or browserify will bundle this all together, and you can use this bundle directly in your Lightning Components.
87-
The main thing is to expose the bundle as a library, and at the bare minimum export the store so that you can set it in the Provider component.
88-
The webpackTodo example also shows how you can use bindActionCreators to export your actions for use in the Lightning Component controllers.
89-
One of the great benefits of using this model is that all your third-party dependencies are kept in one file (or multiple code-splitting files, if you're into that kind of thing), and you can use all the npm goodness like shrinkwrap, update, etc.

addons/src/aura/ReducersCombined/ReducersCombined.evt

Lines changed: 0 additions & 3 deletions
This file was deleted.

addons/src/aura/RootReducer/RootReducer.cmp

Lines changed: 0 additions & 9 deletions
This file was deleted.

addons/src/aura/RootReducer/RootReducerController.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

addons/src/aura/RootReducer/RootReducerHelper.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

addons/src/aura/importReducer/importReducer.evt

Lines changed: 0 additions & 4 deletions
This file was deleted.

addons/src/aura/reducer/reducer.cmp

Lines changed: 0 additions & 9 deletions
This file was deleted.

addons/src/aura/reducer/reducerController.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)