fkp-sax
store data and action X
Last updated 3 years ago by webkixi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install fkp-sax 
SYNC missed versions from official npm registry.

FKP-SAX

SAX mean "store and action X"

// install
npm install fkp-sax --save

It contains three parts, as fellow

namespace data actions
uniqueId {String} {Json} {Function}

Instance/实例化

import SAX from 'fkp-sax'
const saxer = SAX('uniqueName')

API

Instance section

API 描述 例子
bind 绑定CONTEXT saxer.bind(context)
has 是否包含某指定namespace saxer.has(id)

bind: 设置所有actions的方法执行的上下文

Data section

API 描述 例子
data 数据 saxer.data
set 设置数据 saxer.set({Json})
append 追加数据 saxer.append({})

Actions section

API 描述 例子
on mount saxer.on(key, callback)
off unmout saxer.off(key)
emmit run saxer.emmit(key, {Json})
trigger multi-run saxer.trigger()
setActions multi-mount saxer.setActions({Json})
  • key: {String}
  • callback: {Function}

作为内存数据库

as a simple data library in memery
SAX可以作为简易的内存数据库,来存储页面中的变量

import SAX from 'fkp-sax'
const saxer = SAX('uniqueName')
saxer.append({
  aaa: 'i am',
  bbb: 'the king'
})
console.log(saxer.data.aaa)   // i am
console.log(saxer.data.bbb)   // the king

delete saxer.data.aaa
console.log(saxer.data.aaa)   // undefined
console.log(saxer.data.bbb)   // 'the king'

Hooks

as a trigger to performance some predefine method, with ajax or delay data, it's Very useful
SAX可以作为触发器,触发预定义的方法,配合ajax或者延时数据使用

saxer.append({
  hello: '你好'
})
saxer.on('fight', function(){console.log('===== 111')})
saxer.on('fight', function(){console.log('===== 222')})

saxer.on('gogogo', function(data){console.log(data.hello)})

saxer.emmit('fighter')  // 111,  222
saxer.emmit('gogogo', {hello: 'world'})  // world

saxer.trigger()  // 111,  222,  你好

Current Tags

  • 1.5.25                                ...           latest (3 years ago)

45 Versions

  • 1.5.25                                ...           3 years ago
  • 1.5.24-3                                ...           3 years ago
  • 1.5.24-2                                ...           3 years ago
  • 1.5.24-1                                ...           3 years ago
  • 1.5.24                                ...           3 years ago
  • 1.5.23                                ...           3 years ago
  • 1.5.22                                ...           3 years ago
  • 1.5.21-1                                ...           3 years ago
  • 1.5.21                                ...           3 years ago
  • 1.5.20                                ...           3 years ago
  • 1.5.19                                ...           3 years ago
  • 1.5.18                                ...           3 years ago
  • 1.5.17                                ...           3 years ago
  • 1.5.16                                ...           3 years ago
  • 1.5.15                                ...           3 years ago
  • 1.5.14                                ...           3 years ago
  • 1.5.13                                ...           3 years ago
  • 1.5.12                                ...           3 years ago
  • 1.5.11                                ...           3 years ago
  • 1.5.10                                ...           4 years ago
  • 1.5.9                                ...           4 years ago
  • 1.5.8                                ...           4 years ago
  • 1.4.8                                ...           4 years ago
  • 1.4.7                                ...           4 years ago
  • 1.4.6                                ...           4 years ago
  • 1.4.5                                ...           4 years ago
  • 1.4.4                                ...           4 years ago
  • 1.4.3                                ...           4 years ago
  • 1.4.2                                ...           4 years ago
  • 1.4.1                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.10                                ...           4 years ago
  • 1.2.10                                ...           4 years ago
  • 1.2.9                                ...           4 years ago
  • 1.1.9                                ...           4 years ago
  • 1.1.8                                ...           4 years ago
  • 1.0.8                                ...           4 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.6                                ...           4 years ago
  • 1.0.5                                ...           4 years ago
  • 1.0.4                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 49
Last Day 1
Last Week 47
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |