Skip to content

Commit

Permalink
Upgrade devDeps and @dldc/erreur
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne-dldc committed Nov 2, 2023
1 parent 9e7c541 commit e81809a
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 184 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<p align="center">
<img src="https://raw.githubusercontent.com/etienne-dldc/suub/main/design/logo.png" width="597" alt="suub logo">
<img src="https://raw.githubusercontent.com/dldc-packages/pubsub/main/design/logo.png" width="597" alt="pubsub logo">
</p>

# 📫 Suub
# 📫 PubSub

> A simple pub/sub written in Typescript
```
npm install @dldc/pubsub
```

## Gist

```ts
import { Suub } from 'suub';
import { PubSub } from '@dldc/pubsub';

const mySub = Suub.createSubscription<number>();
const mySub = PubSub.createSubscription<number>();

const unsub = mySub.subscribe((num) => {
console.log('num: ' + num);
Expand All @@ -26,28 +30,28 @@ unsub();

### Creating a Subscription

To create a `Subscription` you need to import the `Suub.createSubscription` function and call it.
To create a `Subscription` you need to import the `PubSub.createSubscription` function and call it.

```ts
import { Suub } from 'suub';
import { PubSub } from '@dldc/pubsub';

const subscription = Suub.createSubscription();
const subscription = PubSub.createSubscription();
```

If you use TypeScript, you need to pass a type parameter to the `Suub.createSubscription` function to define the type of the value associated with the subscription.
If you use TypeScript, you need to pass a type parameter to the `PubSub.createSubscription` function to define the type of the value associated with the subscription.

```ts
import { Suub } from 'suub';
import { PubSub } from '@dldc/pubsub';

const numSubscription = Suub.createSubscription<number>();
const numSubscription = PubSub.createSubscription<number>();
```

If you don't want your subscription not to emit any value, you can use the `Suub.createVoidSubscription` function.
If you don't want your subscription not to emit any value, you can use the `PubSub.createVoidSubscription` function.

```ts
import { Suub } from 'suub';
import { PubSub } from '@dldc/pubsub';

const voidSubscription = Suub.createVoidSubscription();
const voidSubscription = PubSub.createVoidSubscription();
```

### Subscribe and Unsubscribe
Expand Down Expand Up @@ -239,10 +243,6 @@ This is a no-op, it will not call `onDestroy` again.

This means that you can't call `emit` or `subscribe` in the `onDestroy` callback and that `isDestroyed` will return `true` in the `onDestroy` callback.

## Examples

Take a look at the [Examples folder](https://github.com/etienne-dldc/suub/tree/master/examples).

## API

```ts
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@
"root": true
},
"dependencies": {
"@dldc/erreur": "^5.0.0"
"@dldc/erreur": "^6.0.0"
},
"devDependencies": {
"@types/node": "^20.8.3",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@types/node": "^20.8.10",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@vitest/coverage-v8": "^0.34.6",
"auto-changelog": "^2.4.0",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"prettier": "^3.0.3",
"release-it": "^16.2.1",
Expand All @@ -103,7 +103,7 @@
"typescript": "^5.2.2",
"vitest": "^0.34.6"
},
"packageManager": "pnpm@8.6.1",
"packageManager": "pnpm@8.9.0",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
Loading

0 comments on commit e81809a

Please sign in to comment.