Skip to content

ZeeCoder/z-namespacer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Namespaces event strings. (Works with jQuery.)

Resources

License

Stars

Watchers

Forks

Packages

No packages published