1.0.0 • Published 10 years ago

z-namespacer v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

z-namespacer

Build Status npm version

Namespacer creates namespaced event strings.

Expects the returned namespaced event strings to be used with jQuery event namespaces.

Since it's a CommonJS module, it must be used alongside with Browserify, or something similar, like WebPacker.

Example, explanation

var Namespacer = require('z-namespacer');

// Creating a new object, providing the namespace
var ns = new Namespacer('namespace');

ns.get('click');
// -> 'click.namespace'

ns.get('resize scroll');
// -> 'resize.namespace scroll.namespace'

// Usage example with jQuery
$(window).on(ns.get('resize scroll'), function() {
    // Do something nasty
});

// later on
$(window).off(ns.get('resize scroll'));

License

MIT

1.0.0

10 years ago