Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kirill-dev-pro/mebus-solid

MeBus, the type-safe native browser event bus, bindings for solid-js
https://github.com/kirill-dev-pro/mebus-solid

Last synced: 2 days ago
JSON representation

MeBus, the type-safe native browser event bus, bindings for solid-js

Awesome Lists containing this project

README

        

# mebus-solid

Solid-js bindings for MeBus, a type-safe message bus for browsers.

## Installation

```bash
npm install mebus-solid
```

## Usage

```tsx
import { useMeBus } from 'mebus-solid';
import { z } from 'zod';

const messageSchema = {
increase: z.object({
number: z.number(),
}),
}

const Display = () => {
const [count, setCount] = createSignal(0);

useMeBus(messageSchema, {
increase: (payload) => setCount(count() + payload.number),
});

return

{count}

}

const Button = () => {
const sendEvent = useMeBus(messageSchema);

return sendEvent('increase', { number: 1 })}>Increase
}

const App = () => {
return (





);
}
```