Code Monkey home page Code Monkey logo

biojs-events's Introduction

event system

This wrapper here is for backbone-events-standalone and thus the Backbone event system.

Guidelines

You can choose any library that supports the choosen syntax.

Please provide

objs.on("name", function(data) {})
objs.off("name", function(data) {})
objs.once("name", function(data) {})
objs.trigger("name", function(data) {})
objs.onAll(function(eventName, data) {})   // (optional)

Here is a list of some popular libraries that offer this functionality:

Not all of them use the same method names or signatures. Please try to adapt those the signatures given above.

How to use

1. install

npm install biojs-events --save

2. Mix the events capability with your object

After the code of your BioJS component add the events capability by mixing you component prototype with the event class

require('biojs-events').mixin(my_component.prototype);

3. Trigger events

Now in your code you can use the events methods (trigger, off,on,once):

self.trigger('onSomethingChanged', {
 data : "some data"
});

and of course listen to your own events:

self.on('onSomethingChanged', function(data){
 console.log(data); // will print "some data"
});

biojs-events's People

Contributors

wilzbach avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.