property-connector
v0.0.3
Published
Just a decorator for connect with subject and transform properties in observable on multiple channels.
Downloads
5
Readme
Property connector with channel name
This library is maybe not a good practice and you can probably make it by yourself
@Connector(channel_name)
Install
npm i property-connector
Use
import Connector from "property-connector";
class Bar {
@Connector('users')
users: Subject<any> | undefined
}
class Foo {
@Connector('users')
users: Subject<any> | undefined
}
let foo = new Foo()
foo.users?.subscribe((next) => console.log(next))
let bar = new Bar()
bar.users?.next({
name: "John"
})
class Zerg {
@Connector('login')
loginEvent: Subject<any> | undefined
login(mail: string, pass: string) {
this.loginEvent?.next({mail, pass})
}
}
class Log {
@Connector('login')
loginEvent: Subject<any> | undefined
}
let log = new Log()
log.loginEvent?.subscribe(log => console.log(log))
let zerg = new Zerg()
zerg.login("[email protected]", "password")
Result
npm run dev
{ name: 'John' }
{ mail: '[email protected]', pass: 'password' }