Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ampersand-wildemitter-datatype-mixin

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-wildemitter-datatype-mixin

WildEmitter datatype for Ampersand state

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ampersand-wildemitter-datatype-mixin

A mixin for linking WildEmitter objects with Ampersand-State so that they can be bound by Ampersand-View.

Requires that the WildEmitter object emits events with this format:

emitter.emit('change:PROPERTY', emitter, 'VALUE');

It must also make the PROPERTY value an accessible attribute in order for things like view bindings to work:

emitter.foo = 'new-foo';
emitter.emit('change:foo', emitter, emitter.foo);

Install

$ npm install ampersand-wildemitter-datatype-mixin

Example

var State = require('ampersand-state');
var WildEmitterMixin = require('ampersand-wildemitter-datatype-mixin');

var StateWithWildEmitter = State.extend(wildemitterMixin, {
    props: {
        wild: 'wildemitter',
    },
    derived: {
        bar: {
            deps: ['wild.foo'],
            cache: false,
            fn: function () {
                return 'it works!';
            }
        }
    }
});

var ex = new StateWithWildEmitter();
ex.wild = new WildEmitter();

ex.on('change:bar', function () {
  console.log(ex.bar);
});

ex.wild.emit('change:foo', ex.wild, 'newfoo');
// -> it works!

License

MIT

FAQs

Package last updated on 24 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc