estrattonbailey / evx

Handy dandy persistent-state pub/sub with multi, wildcard, and single-property subscriptions.
25 stars 2 forks source link

Pub/sub to property names? #2

Closed estrattonbailey closed 5 years ago

estrattonbailey commented 5 years ago

Could lend some added specificity and flexibility. Would only support top-level keys, not nested properties (though this library doesn't deep merge anyway, so no one should really be using nested keys in the first place).

import { on, emit } from 'evx'

on('somePropertyKey', () => {}) // #1
on('foo', () => {}) // #2

emit('foo', { somePropertyKey: true }) // would fire #1 & #2

emit('somePropertyKey') // would fire only #1