0.1.3 altered emitter values in setter and added on for just property name

master
David Kebler 2020-06-16 09:53:36 -07:00
parent c5da6ba7c4
commit 41e41683a0
3 changed files with 12 additions and 9 deletions

View File

@ -19,7 +19,7 @@ console.log('instance before doing rx on properties\n')
console.log(example)
console.log('--------------------------')
example.on('changed', (prop) => console.log('emitted----a property changed-----',prop))
example.on('changed', prop => console.log('emitted----a property changed-----',prop))
example.on('test', (val) => console.log('emitted value of test',val))
console.log('making \'test\' reactive with default amend of add 3')
@ -44,6 +44,9 @@ console.log('making a deeper property \'another.foo\' reactive')
console.log('changing any default amend function ',example.rxAmendValue(val=> val + ':amended'))
example.rxAdd('another.foo')
example.on('foo', (val,path) => { console.log('emitted via just \'foo\' ',val,'path is also emitted:',path)})
example.on('another.foo', (val,path) => { console.log('emitted via just \'another.foo\',',val,'path is undefined',path)})
example.another.foo = 7
console.log('direct access of another.foo',example.another.foo)
@ -77,3 +80,8 @@ console.log('getting directy:',example.a)
console.log('using $get with passed object:',example.$get(example.a.test,'object.do'))
console.log('deleting do prop only', example.$del(example.a,'test.object.do',true))
console.log('it\'s gone see:',example.a)
example.on('demo',(value) => {
console.log('shoud do simple emit of test>', value)
})
example.emit('demo','test')

View File

@ -1,6 +1,6 @@
{
"name": "@uci-utils/rx-class",
"version": "0.1.2",
"version": "0.1.3",
"description": "class that support reactive properites",
"main": "src/rx-class.js",
"scripts": {

View File

@ -99,8 +99,9 @@ export default class RxClass extends EventEmitter {
rx.value = value
value = rx.amendValue(value,path)
rx.obs.next(value)
self.emit(opts.event || self._rx_.event,value)
self.emit(opts.event || self._rx_.event,value,path)
self.emit(path,value)
self.emit(name,value,path)
// any hook function that already bound will use that context
self._rx_.hooks.forEach(hook=>hook.call(self,value))
rx.hooks.forEach(hook=>hook.call(self,value))
@ -174,12 +175,6 @@ export default class RxClass extends EventEmitter {
}
}
return false
// else {
// if (name && name!=='_default') {
// console.log('*********no rx object at that path*******')
// console.log('================================')
// }
// }
}
// takes several formats for a path to an objects property and return only the . string