@ainc/utils

utils

Usage no npm install needed!

<script type="module">
  import aincUtils from 'https://cdn.skypack.dev/@ainc/utils';
</script>

README

@ainc/observer

Observer

Install

$ yarn add @ainc/observer

Usage

import observer from '@ainc/observer';

// create
const { subscribe, notify } = observer();

// subscribe
const unsubscribe = subscribe((...args) => console.log(args));

// unsubscribe
unsubscribe();

// notify
notify(1, 2, 3);

Class: Observer

subscribe(listener: Function): Function

add listener, return unsubscribe handler.

notify(...args: any[]): Promise

notify observer, return the Promise for all the subscribe handler resolved.