Skip to content

Instantly share code, notes, and snippets.

@vadirn
Last active February 9, 2017 06:59
Show Gist options
  • Save vadirn/39db367f77e9c200eac462219b9382ba to your computer and use it in GitHub Desktop.
Save vadirn/39db367f77e9c200eac462219b9382ba to your computer and use it in GitHub Desktop.
import { injectDeps } from 'components-di';
import RootComponent from '../../ui/views/Example';
class ExampleController {
constructor(initialState, context) {
// context has store reference and a function to replace controller
this._context = context;
this._context.store.resetState(initialState);
this._view = injectDeps(this.context, this.actions)(RootComponent);
}
// sometimes we need to clean up after controller,
// dispose is called every time when controller is replaced
dispose() { }
get context() {
return this._context;
}
get actions() {
return { };
}
get view() {
return this._view;
}
};
export default ExampleController;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment