Comparing version 0.2.2 to 0.2.3
@@ -45,3 +45,21 @@ /** | ||
}, | ||
childContextTypes: { | ||
getStore: React.PropTypes.func, | ||
executeAction: React.PropTypes.func | ||
}, | ||
/** | ||
* Provides the current context as a child context | ||
* @method getChildContext | ||
*/ | ||
getChildContext: function(){ | ||
var context = {}; | ||
Object.keys(FluxibleMixin.childContextTypes).forEach(function (key) { | ||
context[key] = (this.props.context && this.props.context[key]) || this.context[key]; | ||
}, this); | ||
return context; | ||
}, | ||
/** | ||
* Registers staticly declared listeners | ||
@@ -48,0 +66,0 @@ * @method componentDidMount |
{ | ||
"name": "fluxible", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "A pluggable container for isomorphic flux applications", | ||
@@ -26,3 +26,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"chai": "^1.10.0", | ||
"chai": "^2.0.0", | ||
"cheerio": "^0.18.0", | ||
@@ -34,3 +34,3 @@ "connect-livereload": "^0.5.2", | ||
"istanbul": "^0.3.2", | ||
"jsdom": "^1.0.0-pre.3", | ||
"jsdom": "^3.1.2", | ||
"jshint": "^2.5.5", | ||
@@ -37,0 +37,0 @@ "mocha": "^2.0.1", |
114
README.md
@@ -182,119 +182,13 @@ # Fluxible | ||
## API | ||
[//]: # (API_START) | ||
### Fluxible | ||
## APIs | ||
Instantiated once across all requests, this holds settings and interfaces that are used across all requests/sessions. | ||
- [Fluxible](https://github.com/yahoo/fluxible/blob/master/docs/fluxible.md) | ||
- [FluxibleContext](https://github.com/yahoo/fluxible/blob/master/docs/fluxible-context.md) | ||
#### Constructor | ||
Creates a new application instance with the following parameters: | ||
* `options`: An object containing the application settings | ||
* `options.appComponent` (optional): Stores your top level React component for access using getAppComponent() | ||
#### createContext(contextOptions) | ||
Creates a new FluxibleContext instance passing the `contextOptions` into the constructor. Also iterates over the plugins calling `plugContext` on the plugin if it exists in order to allow dynamic modification of the context. | ||
#### plug(plugin) | ||
Allows custom application wide settings to be shared between server and client. Also allows dynamically plugging the FluxibleContext instance each time it is created by implementing a `plugContext` function that receives the context options. | ||
#### getPlugin(pluginName) | ||
Provides access to get a plugged plugin by name. | ||
#### registerStore(store) | ||
Passthrough to [dispatchr's registerStore function](https://github.com/yahoo/dispatchr#registerstorestoreclass) | ||
#### getAppComponent() | ||
Provides access to the `options.appComponent` that was passed to the constructor. This is useful if you want to create the application in a file that is shared both server and client but then need to access the top level component in server and client specific files. | ||
#### dehydrate(context) | ||
Returns a serializable object containing the state of the Fluxible and passed FluxibleContext instances. This is useful for serializing the state of the application to send it to the client. This will also call any plugins which contain a dehydrate method. | ||
#### rehydrate(state) | ||
Takes an object representing the state of the Fluxible and FluxibleContext instances (usually retrieved from dehydrate) to rehydrate them to the same state as they were on the server. This will also call any plugins which contain a rehydrate method. | ||
### FluxibleContext | ||
Instantiated once per request/session, this provides isolation of data so that it is not shared between requests on the server side. | ||
#### Constructor | ||
Creates a new context instance with the following parameters: | ||
* `options`: An object containing the context settings | ||
* `options.app`: Provides access to the application level functions and settings | ||
#### createElement(props) | ||
Instantiates the app level React component (if provided in the constructor) with the given props with an additional `context` key containing a ComponentContext. This is the same as the following assuming AppComponent is your top level React component: | ||
```js | ||
AppComponent({ | ||
context: context.getComponentContext(); | ||
}); | ||
``` | ||
#### executeAction(action, payload, callback) | ||
This is the entry point into an application's execution. The initial action is what begins the flux flow: action dispatches events to stores and stores update their data structures. On the server, we wait for the initial action to finish and then we're ready to render using React. On the client, the components are already rendered and are waiting for store change events. | ||
Parameters: | ||
* `action`: A function that takes three parameters: `actionContext`, `payload`, `done` | ||
* `payload`: the action payload | ||
* `done`: the callback to call when the action has been completed | ||
```js | ||
var action = function (actionContext, payload, done) { | ||
// do stuff | ||
done(); | ||
}; | ||
context.executeAction(action, {}, function (err) { | ||
// action has completed | ||
}); | ||
``` | ||
#### plug(plugin) | ||
Allows custom context settings to be shared between server and client. Also allows dynamically plugging the ActionContext, ComponentContext, and StoreContext to provide additional methods. | ||
#### getActionContext() | ||
Generates a context interface providing access to only the functions that should be called from actions. By default: `dispatch`, `executeAction`, and `getStore`. | ||
This action context object is used every time an `executeAction` method is called and is passed as the first parameter to the action. | ||
#### getComponentContext() | ||
Generates a context interface providing access to only the functions that should be called from components. By default: `executeAction`, `getStore`. `executeAction` does not allow passing a callback from components so that it enforces actions to be send and forget. | ||
This context interface should be passed in to your top level React component and then sent down to children as needed. These components will now have access to listen to store instances, execute actions, and access any methods added to the component context by plugins. | ||
#### getStoreContext() | ||
Generates a context interface providing access to only the functions that should be called from stores. By default, this is empty. See [store constructor interface](https://github.com/yahoo/dispatchr#constructor) for how to access this from stores. | ||
#### dehydrate() | ||
Returns a serializable object containing the state of the FluxibleContext and its Dispatchr instance. This is useful for serializing the state of the current context to send it to the client. This will also call any plugins whose plugContext method returns an object containing a dehydrate method. | ||
#### rehydrate(state) | ||
Takes an object representing the state of the FluxibleContext and Dispatchr instances (usually retrieved from dehydrate) to rehydrate them to the same state as they were on the server. This will also call any plugins whose plugContext method returns an object containing a rehydrate method. | ||
[//]: # (API_STOP) | ||
## License | ||
This software is free to use under the Yahoo! Inc. BSD license. | ||
This software is free to use under the Yahoo Inc. BSD license. | ||
See the [LICENSE file][] for license text and copyright information. | ||
[LICENSE file]: https://github.com/yahoo/fluxible/blob/master/LICENSE.md |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93579
29
657
194