open-index/open-npm huggingface dataset:
npm package: @seliseblocks/notifications
Description: A modern ESM-based SignalR notification package.
Latest version: 0.0.5

# @seliseblocks/notifications

Blocks cloud's notification package.

## Features

- Connects to a notification hub
- Dynamically loads notification channels from your API
- Handles authentication via access token factory
- Simple subscription and cleanup API

## Installation

```sh
npm install @seliseblocks/notifications
```

## Usage

```js
import { subscribeNotifications } from "@seliseblocks/notifications";

const apiBaseUrl = "https://your-api-url";
const projectKey = "your-project-key";
const accessTokenFactory = () => "your-access-token";

const { stop } = await subscribeNotifications(
  apiBaseUrl,
  {
    projectKey,
    configSize: 100, // optional, default is 100
    accessTokenFactory
  },
  (channel, message) => {
    console.log(`Received message on channel ${channel}:`, message);
  }
);

// To stop receiving notifications:
await stop();
```

## API

### subscribeNotifications(apiBaseUrl, options, onMessage)

- `apiBaseUrl` (string): Base URL for your API.
- `options` (object):
  - `projectKey` (string): Unique key for your project.
  - `configSize` (number, optional): Number of configs to fetch (default: 100).
  - `accessTokenFactory` (function): Returns a valid access token.
- `onMessage` (function): Callback `(channel, message)` for incoming notifications.

Returns: `{ stop: () => Promise<void> }`

## License

MIT