https://github.com/zeecoder/z-namespacer
Namespaces event strings. (Works with jQuery.)
https://github.com/zeecoder/z-namespacer
Last synced: 10 months ago
JSON representation
Namespaces event strings. (Works with jQuery.)
- Host: GitHub
- URL: https://github.com/zeecoder/z-namespacer
- Owner: ZeeCoder
- License: mit
- Created: 2015-06-11T14:39:13.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-12T06:42:22.000Z (over 10 years ago)
- Last Synced: 2025-01-27T13:14:21.356Z (12 months ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# z-namespacer
[](https://travis-ci.org/ZeeCoder/z-namespacer)
[](http://badge.fury.io/js/z-namespacer)
Namespacer creates namespaced event strings.
Expects the returned namespaced event strings to be used with [jQuery event namespaces](https://api.jquery.com/event.namespace/).
Since it's a CommonJS module, it must be used alongside with [Browserify](http://browserify.org/), or
something similar, like [WebPacker](http://webpack.github.io/).
## Example, explanation
```js
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](LICENSE)