2.0.1 • Published 8 years ago

fdz-hook v2.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

FDZ Hooks

A simple way to add hooks in any javascript aplication - Vanilla JS

Browser Support

This library relies on Map API. And this API is supported in the following browsers.

ChromeFirefoxOperaSafariIE
49+ ✔54+ ✔47+ ✔10.1+ ✔11 ✔

Dependencies

This library is totally make in Vanilla JS

Installation

$ npm install fdz-hook --save

How to use

ES6

// to import a specific method
import Hook from 'fdz-hook';

const hook = new Hook();

// using  method
hook.register('click', () => console.log('Works!'));

CommonJS

const Hook = require('fdz-hook');

const hook = new Hook();

UMD in Browser

<!-- to import non-minified version -->
<script src="fdz-hook.umd.js"></script>

<!-- to import minified version -->
<script src="fdz-hook.umd.min.js"></script>

After that the library will be available to the Global as Hook. Follow an example:

const hook = new Hook();

hook.register('beforeOpen', () => {
  console.log('Opening!');
});

Methods

Follow the methods that the library provides.

hook.register(name, fn)

Register a hook inside hook object

Arguments

ArgumentTypeOptions
namestring'inform a hook name'
fnfunction'provide a callback'

Example

hook.register('beforeMount', (instance) => {
  // do something
});

hook.call(name, args1, args2...)

Call a hook from hook object

Arguments

ArgumentTypeOptions
namestring'inform a hook name'
argsany'provide arguments one by one'

Example

hook.call('beforeMount', { name: 'Lorem' });

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

Daniel Simão
Daniel Simão

See also the list of colaborators who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

2.0.1

8 years ago

2.0.0

8 years ago

1.0.2

8 years ago

1.0.0

8 years ago