Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/kirill-dev-pro/mebus-solid
- Owner: kirill-dev-pro
- Created: 2024-03-03T12:31:51.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-03-03T15:32:21.000Z (8 months ago)
- Last Synced: 2024-05-30T16:39:53.241Z (5 months ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 (
);
}
```