use-signal
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

use-signal

simple hook to create and dispatch events across a react like app

Usage

// signal.ts
import {createSignal} from "use-signal";

export const signal = createSignal(); // or createSignal("name");

// App.ts

import {signal} from "./signal";
import {useSignal} from "use-signal/react";
function App() {
  useSignal(signal, callback);
  //...
}
// somewhere else

import {dispatchSignal} from "use-signal";
import {signal} from "./signal";

dispatchSignal(signal); // callback is called in App.ts

Readme

Keywords

none

Package Sidebar

Install

npm i use-signal

Weekly Downloads

0

Version

0.2.2

License

MIT

Unpacked Size

5.79 kB

Total Files

24

Last publish

Collaborators

  • hydrophobefireman