Skip to content

petermoresi/foundrystore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

foundry-store

foundry-store is a general purpose state management built on FunctionFoundry and Fluxury.

This library does not specify data fetching. Use jQuery, XHR, fetch, websockets and other common solutions to access data.

Getting Started

Option A) Install from npm.

$ npm install --save foundry-store

Require into your project.

var createStore = require('foundry-store') // Node.js / browserify / webpack
// or
import createStore from 'foundry-store' // ES6 syntax

Option B) Install from dist folder.

<html>
  <head>
    <script src="/path/to/general-store.js"><script>
    ...

Basic Usage

var store = createStore()
store.set({ key: 'value' })
store.get('key')

store.set({ todos: [{ c: true, m: 'Feels' }, { c: true, m: 'so good' }]}) // c is for checked and m for message
store.setFilter({
  table: 'todos',
  field: 'm',
  op: 'eq',
  value: 'so good'}
)
store.get('todos') // => [{ m: 'so good' }]

Advanced Usage

// Add custom query methods
var store = createStore({
  combineTodos: (state) => state.todos.map(d => d.m).join()
  getCheckedCount: (state) => state.todos.filter(d => d.c).length
}, {
  setTodos: (todos) => {
    this.set({ todos: todos })
  }
})


store.setTodos([{ c: true, m: 'Feels' }, { c: false, m: 'so good' }])
// of store.set({ todos: [{ c: true, m: 'Feels' }, { c: false, m: 'so good' }] })


store.combineTodos() // => 'Feels so good'
store.getCheckedCount() // => 1

About

UNMAINTAINED!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published