0.2.6 • Published 6 years ago

quiver-react-support v0.2.6

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

React support package for Quiver framework

Extending Quiver framework in order to bring support for Dependency injection, View-models of MVVM and event driven architecture into React.

How to use Injector

Configure application context:

import {ApplicationContext} from "quiver-react-support";

const {injector} = new ApplicationContext(/*List of app modules, if any go here*/);
/**
 * Create service mapping that'll create new instance of a service for each consumer
 */
injector.map(SomeService);
/**
 * Create a singleton service - first instance created will be served to each following consumer
 */
injector.map(SomeService).asSingleton();
/**
 * Or we can split service interface from it's implementation, creating strong abstraction 
 * between interface and implementation.
 */
injector.map(AbstractService).toType(AbstractServiceImplementation);
/**
 * Or we can map anything to pre-fabricated value, like this:
 */
injector.map(SomeService).toValue({foo: 1, bar: 2, lee: 3});

Access injected values from React component:

import {Component, Inject} from "quiver-react-support";

export class DisplayComponent extends Component {
    
    @Inject()
    private service: SomeService;
    
    render() {
        return `SomeService is accessible like: ${this.service}`;
    }
    
}
0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.4-0

6 years ago

0.2.3-0

6 years ago

0.2.2-0

6 years ago

0.2.1-dev

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago