Skip to content

Instantly share code, notes, and snippets.

@redgeoff
Last active November 4, 2018 04:34
Show Gist options
  • Save redgeoff/f51de757ce85e12e3d5794b11ec45e17 to your computer and use it in GitHub Desktop.
Save redgeoff/f51de757ce85e12e3d5794b11ec45e17 to your computer and use it in GitHub Desktop.
MSON Talk: EventEmitters
// Instantiate with default prop
const component = new MyComponent({ firstName: 'Robert' });
// Listener that is run when lastName changes
component.on('lastName', value => { /* new lastName */ });
// Set props
component.set({ firstName: 'Bob', lastName: 'Marley' });
component.get('firstName'); // Bob
component.get(['firstName', 'lastName']); // { firstName: 'Bob', lastName: 'Marley' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment