0.0.13 โ€ข Published 2 years ago

@infini-soft/lib-hub v0.0.13

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

Getting started

Typescript Ultra Small Event Hub.

โœจ Features

  • Event Pub/Sub
  • Strongly typed
  • 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/hub

๐Ÿ“ฆ Install

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

๐Ÿ”จ Examples

React

import React from 'react';
import { hub, consoleplugin } from '@infini-soft/lib-hub';

const { subscribe, error, info } = hub();
subscribe(consoleplugin);

export default () => {
  return (
    <>
      <h3>Error in console</h3>
      <button
        onClick={() => {
          error('Example error in console');
        }}
      >
        Test
      </button>

      <button
        onClick={() => {
          error(
            { description: 'Example error in console with formatted output', format: true },
            'Example',
          );
        }}
      >
        Format
      </button>

      <button
        onClick={() => {
          error(
            {
              description: 'Example error in console with verbose context',
              format: true,
              verbose: true,
              context: { prop: 'im a context props' },
            },
            'Example',
          );
        }}
      >
        Format
      </button>

     <h3>Info in console</h3>
      <button
        onClick={() => {
         info('Example info in console');
        }}
      >
        Test
      </button>

      <button
        onClick={() => {
          info(
            { description: 'Example info in console with formatted output', format: true },
            'Example',
          );
        }}
      >
        Format
      </button>

      <button
        onClick={() => {
          info(
            {
              description: 'Example info in console with verbose context',
              format: true,
              verbose: true,
              context: { prop: 'im a context props' },
            },
            'Example',
          );
        }}
      >
        Format
      </button>
    </>
  );
};

๐Ÿ“š Methods

NameType
debug(description: string, source?: string) => void<T>(payload: T, source?: string) => void<T>(payload: T, source?: string) => void
emit<T>(event: string, message?: T, source?: string) => void
error(description: string, source?: string) => void<T>(payload: T, source?: string) => void<T>(payload: T, source?: string) => void
info(description: string, source?: string) => void<T>(payload: T, source?: string) => void<T>(payload: T, source?: string) => void
on<T>(event: string, handler: Handler<ExecutionPayload<T>>) => () => void
subscribe<T>(handler: Handler<ExecutionPayload<T>>) => () => void
success(description: string, source?: string) => void<T>(payload: T, source?: string) => void<T>(payload: T, source?: string) => void
warn(description: string, source?: string) => void<T>(payload: T, source?: string) => void<T>(payload: T, source?: string) => void

๐Ÿงช Unit Tested

npm.io


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

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

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