vivy-subscription
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

vivy-subscription

NPM Version License

A Vivy plugin which extend Vivy model to watch history or something else to update state by dispatching a reducer or action.

Docs

Installation

Using npm:

$ npm install vivy vivy-subscription

Examples

Examples in repository

$ cd ./examples/[EXAMPLE_NAME]
$ npm run start

Example names:

Complete and real project example

Documentation

Basic usage

index.js

import React from 'react';
import {render} from 'react-dom';
import {Provider} from 'react-vivy';

// Import Vivy
import Vivy from 'vivy';

// Import Vivy subscription plugin
import vivySubscription from 'vivy-subscription';

// Import your component and model
import App from 'path_to_app_component';
import app from 'path_to_app_model';

// Create vivy
const vivy = Vivy();

// Apply subscription plugin
vivy.use(vivySubscription());

// Create store after configuration
const store = vivy.createStore();

// Register vivy model
store.registerModel(app);

render(
    <Provider store={store}>
        <App/>
    </Provider>,
    document.getElementById('app-container')
);

app.js

export default {
    nameSpace: 'app',
    state: null,
    subscriptions: {

        // Define a subscription
        yourSubscription: ({history}) => (dispatch, getState) => {
            // Bind history listening or do something else
        }

    }
};

Package Sidebar

Install

npm i vivy-subscription

Weekly Downloads

25

Version

3.2.0

License

MIT

Unpacked Size

15.1 kB

Total Files

11

Last publish

Collaborators

  • fatalxiao