z-namespacer

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i z-namespacer

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • zeecoder