Declarative streams for Typescript
See the codeEventkit is a library for defining, composing, and observing asynchronous streams of data.
You can learn more about the use cases and features of Eventkit in the official documentation.
The best way to start using Eventkit is by checking out the getting started guide.
Here's a basic example of how to use an eventkit stream— a common object used to represent data that will be emitted elsewhere in your application:
import { Stream, filter } from "@eventkit/base";
// Create a stream of events
const stream = new Stream<{ type: string; payload: any }>();
// Filter for specific event types
const userEvents = stream.pipe(filter((event) => event.type.startsWith("user.")));
// Subscribe to the filtered stream
userEvents.subscribe((event) => {
console.log(`Received user event: ${event.type}`);
});
// Push events to the stream
stream.push({ type: "user.login", payload: { userId: "123" } });
stream.push({ type: "system.update", payload: { version: "1.0.1" } }); // This won't be logged
// Wait for all events to be processed
await stream.drain();
View the official eventkit documentation here.
We welcome contributions! Please see our CONTRIBUTING.md guide for more information on how to get involved.
Distributed under the MIT License. See the LICENSE for more information.
314 commits
5 commits
TypeScript
99.1%
Declarative streams for Typescript
See the codeEventkit is a library for defining, composing, and observing asynchronous streams of data.
You can learn more about the use cases and features of Eventkit in the official documentation.
The best way to start using Eventkit is by checking out the getting started guide.
Here's a basic example of how to use an eventkit stream— a common object used to represent data that will be emitted elsewhere in your application:
import { Stream, filter } from "@eventkit/base";
// Create a stream of events
const stream = new Stream<{ type: string; payload: any }>();
// Filter for specific event types
const userEvents = stream.pipe(filter((event) => event.type.startsWith("user.")));
// Subscribe to the filtered stream
userEvents.subscribe((event) => {
console.log(`Received user event: ${event.type}`);
});
// Push events to the stream
stream.push({ type: "user.login", payload: { userId: "123" } });
stream.push({ type: "system.update", payload: { version: "1.0.1" } }); // This won't be logged
// Wait for all events to be processed
await stream.drain();
View the official eventkit documentation here.
We welcome contributions! Please see our CONTRIBUTING.md guide for more information on how to get involved.
Distributed under the MIT License. See the LICENSE for more information.
314 commits
5 commits
TypeScript
99.1%