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

fruitmachine-bindall

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

fruitmachine-bindall

A fruitmachine helper that binds all the methods in fruitmachine modules to each instance.

  • 1.0.0
  • npm
  • Socket score

Version published
Weekly downloads
439
increased by56.23%
Maintainers
1
Weekly downloads
 
Created
Source

fruitmachine-bindAll

A fruitmachine helper that binds all the methods in fruitmachine modules to each instance.

Example

var Apple = fruitmachine.define({
  name: 'apple',
  initialize: function() {
    this.onButtonClick = this.onButtonClick.bind(this);
  },
  setup: function() {
    this.el.addEventListener('click', this.onButtonClick);
  },
  onButtonClick: function() {
    this.fire('buttonclick');
  },
  teardown: function() {
    this.el.removeEventListener('click', this.onButtonClick);
  }
});

... simplies to this ...

var Apple = fruitmachine.define({
  name: 'apple',
  helpers: [require('fruitmachine-bindAll')],
  setup: function() {
    this.el.addEventListener('click', this.onButtonClick);
  },
  onButtonClick: function() {
    this.fire('buttonclick');
  },
  teardown: function() {
    this.el.removeEventListener('click', this.onButtonClick);
  }
});

(This makes more of an impact as modules become more complex)

Why isn't this the default behaviour of fruitmachine?

Because we believe it isn't always needed (and sometimes isn't expected).

Author

  • Wilson Page - @wilsonpage

Contributors

License

Copyright (c) 2013 The Financial Times Limited Licensed under the MIT license.

Credits and collaboration

All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request. Enjoy...

Keywords

FAQs

Package last updated on 28 Oct 2013

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