0.0.9 โ€ข Published 2 years ago

@infini-soft/lib-events v0.0.9

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

Getting started

Typescript Ultra Small Event (~400 bytes) Publisher/Subscribers.

โœจ Features

  • Event Pub/Sub
  • Strongly typed
  • Ultra small (~400 bytes)
  • NodeJS/Browser

๐Ÿ“š Documentation

Get all documentations, examples and execute it directly from our website, the โ˜• kitchen! Come cook software :) https://www.kitchen.infini-soft.com/libraries/events

๐Ÿ“ฆ Install

$ npm install @infini-soft/lib-events --save
# or
$ yarn add @infini-soft/lib-events

๐Ÿ”จ Examples

React

import React from 'react';
import { events } from '@infini-soft/lib-events';

export default () => {
  const { on, fire } = events();
  React.useEffect(() => {
    on('test', (payload) => {
      alert(payload.message);
    });
  }, []);

  return (
    <>
      <h3>Fire test event</h3>
      <button
        onClick={() => {
          fire('test', 'Hello');
        }}
      >
        Test
      </button>
    </>
  );
};

Node

import { events } from '@infini-soft/lib-events';

const { on, fire } = events();
on("test", console.log)

fire('test', 'Hello');

๐Ÿ“š Methods

NameTypeDescription
fire<T>(event: string, message?: T, source?: string) => voidFires an event
on<T>(event: string, handler: Handler<T>) => () => voidSubscribe to event
onAll<T>(handler: Handler<T>) => () => voidSubscribe to all events

๐Ÿงช Unit Tested

npm.io


Powered ๐Ÿš€ by Infinisoft Inc. Wanna cook the future? Come in the kitchen https://www.kitchen.infini-soft.com

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.1

2 years ago