Gathering detailed insights and metrics for observable-mixin
Gathering detailed insights and metrics for observable-mixin
Gathering detailed insights and metrics for observable-mixin
Gathering detailed insights and metrics for observable-mixin
can-observable-mixin
Define properties on JavaScript classes
react-observable-mixin
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.
observable-properties-mixin
Features to generate observable properties mixin
with-observable
Lightweight observable mixin
npm install observable-mixin
Typescript
Module System
Node Version
NPM Version
66.7
Supply Chain
95.1
Quality
75
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
800
Last Day
1
Last Week
1
Last Month
3
Last Year
50
2 Commits
2 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
observable-mixin@1.0.0
Size
28.34 kB
NPM Version
4.0.5
Node Version
7.4.0
Publised On
10 Jan 2017
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-50%
1
Compared to previous week
Last month
200%
3
Compared to previous month
Last year
-26.5%
50
Compared to previous year
Just observe
Mixin that makes your types observable without exposing emitter.
1 npm install --save observable-mixin
observable-mixin
brings 1 method:
subscribe(eventName: String, handler: Function, [once: Boolean]): Function
returns a function that unsubscribes a given listenerThe mixin comes as a factory function i.e. in order to get mixin it needs to invoke exported function. It is done intentionally in order to be able to pass any kind of implementation of EventEmitter.
1 2 import Symbol from 'es6-symbol'; 3 import composeClass from 'compose-class'; 4 import ObservableMixin from 'observable-mixin'; 5 import { EventEmitter } from 'events'; 6 7 const FIELDS = { 8 emitter: Symbol('emitter'), 9 name: Symbol('name') 10 }; 11 12 const Person = composeClass({ 13 mixins: [ 14 ObservableMixin(FIELDS.emitter) 15 ], 16 17 constructor(name) { 18 this[FIELDS.emitter] = new EventEmitter(); 19 this[FIELDS.name] = name; 20 }, 21 22 name(value) { 23 if (value) { 24 this[FIELDS.name] = value; 25 this[FIELDS.emitter].emit('change', 'name', value); 26 } 27 28 return this[FIELDS.name]; 29 } 30 }); 31
1import Person from './person'; 2 3const person = new Person('Mike Wazowski'); 4 5const unsubscribe = person.subscribe('change', (field, value) => { 6 console.log('Person\'s', field, 'was changed to', value); 7}); 8 9person.name('James P. Sullivan'); // Person's name was changed to 'James P. Sullivan' 10 11unsubscribe(); 12 13person.name('Randall Boggs'); // Nothing 14
Mixin supports once
subscription:
1import Person from './person'; 2 3const person = new Person('Mike Wazowski'); 4 5person.subscribe('change', (field, value) => { 6 console.log('Person\'s', field, 'was changed to', value); 7}, true); 8 9person.name('James P. Sullivan'); // Person's name was changed to 'James P. Sullivan' 10 11person.name('Randall Boggs'); // Nothing 12
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/2 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
67 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More