nv-facutil-reactivize

1.0.5 • Public • Published

nv-facutil-reactivize

  • nv-facutil-reactivize is a very simple util to make methods-of-Class listenable

install

  • npm install nv-facutil-reactivize

usage

  const {reactivize,CMMN_METHODS_FILTER} = require("nv-facutil-reactivize");
  
  //reactivize(PCls,specific_fltr,cmmn_fltr)
  //PCls : Parent-Class
  //specific_fltr: filter-of-methods-in-parent-class
  //cmmn_fltr:     common-filter,such as construtcor

example

//specific_fltr for Array
const ARRAY_METHODS_FILTER = []

var RArray = reactivize(Array,ARRAY_METHODS_FILTER,CMMN_METHODS_FILTER)

var arr = new RArray()

//listen for push method
// e.data = {rslt:<the returned rets>,params:<the arguments>}
//
arr.regis_$push$_handler(e=>{console.log(e,e.data)})

> arr.push(10)
E {
  type: 'push',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 49738.11588096619
} { params: [ 10 ], rslt: 1 }
1
>
> arr
ReactiveArray(1) [ 10 ]
>
> arr.push(10,20)
E {
  type: 'push',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 91699.88149785995
} { params: [ 10, 20 ], rslt: 3 }
3
> arr
ReactiveArray(3) [ 10, 10, 20 ]
>

API

  • fac_rv.CMMN_METHODS_FILTER
  • fac_rv.reactivize(PCls,specific_fltr,cmmn_fltr)
  • fac_rv.get_methods_from_pcls(PCls,specific_fltr,cmmn_fltr)
  • fac_rv.creat_inherit_methods_for_rcls(pmethods)
  • fac_rv.add_listeners_to_rcls(RCls,names)
  • fac_rv.add_cumethods_to_rcls(RCls,names,cumethods)

LICENSE

  • ISC

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i nv-facutil-reactivize

    Weekly Downloads

    1

    Version

    1.0.5

    License

    ISC

    Unpacked Size

    5.4 kB

    Total Files

    3

    Last publish

    Collaborators

    • ihgazni2