Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

erickmerchant/combine-stores

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@erickmerchant/combine-stores

Meant to be used with @erickmerchant/framework, it can be used to construct a store that's easy to organize. It defines a state that is an object and each store that you define handles a single property on that object.

/* an example */

const framework = require('@erickmerchant/framework')

/* here is the relevant stuff */

const container = require('@erickmerchant/combine-stores')

const store = container(function (define) {
  define('errors', require('./stores/errors'))
  define('fetchingCount', require('./stores/fetching-count'))
  define('tasks', require('./stores/tasks'))
})

/* end relevant */

const component = require('./component.js')

const target = document.querySelector('main')

const yo = require('yo-yo')
const diff = yo.update

framework({target, store, component, diff})

API Reference

container

container((define) => { ... })

The function exported by this module.

define

define(property, store)

  • property: the property that the store will handle
  • store: a store. When it is called it is only passed the property that it handles as the first argument. When called with no arguments it should return the default for that property.

About

A module to create a store from other stores where each is responsible for one property in the state.

Resources

License

Stars

Watchers

Forks

Packages

No packages published