iocjs
iocjs is an easy for peer invoking
Usage scenario
- you can call a function without it defined
- your invoke will wait for the fn register
- it will work in browser and node
- it wrapped with promise
how to install
//install
npm i peeriocjs --save
how to use
- detail @ src/test.*.js
- here is Recommended Usage
//chain invoke//here is invokerequire("peeriocjs").invoke("fn1").fn1("hello good day").then(function(data){ console.log("here is then")}) //here is registerrequire("peeriocjs").reg("fn1",function(p1){console.log("divide chain success:" + p1 + " "+ this.LiSA)},{ LiSA : "love and peace"})
// recomand operation//here is invokevar i1154 = require("peeriocjs").module("1154").invoke(["fn1","config"]) i1154.fn1("hello good day")i1154.config().then(function(config){ console.log("config value :" + config.name)}) // here is regvar m1154 = require("peeriocjs").module("1154")m1154.reg([ { name:"fn1", fn:function(p1){ console.log("recommanded is success:" + p1) return "yes" } }, { name:"config", fn:function(){ return { name : "LiSA" } } }])
// here test syncvar v = require('peeriocjs').module("abc").invoke("fn").sync.fn("hello good day")console.log("v:" + v);console.log("here should behind v")require('peeriocjs').module("abc").reg("fn",function(p1){ return "params:" + p1})