Socket
Socket
Sign inDemoInstall

fruitmachine-bindall

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

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.


Version published
Maintainers
1
Install size
4.18 kB
Created

Readme

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

Last updated on 27 Mar 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc