@ukon1990/subscription-manager
Advanced tools
Comparing version 1.1.0-beta.4 to 1.1.1
{ | ||
"name": "@ukon1990/subscription-manager", | ||
"version": "1.1.0-beta.4", | ||
"version": "1.1.1", | ||
"description": "This does hopefully make subscription management less tedious, and helps clean up your code with less variables.", | ||
@@ -10,3 +10,3 @@ "main": "dist/index.js", | ||
"test": "jest", | ||
"publish": "tsc & npm publish --access public" | ||
"publish": "tsc && npm publish --access public" | ||
}, | ||
@@ -13,0 +13,0 @@ "keywords": [ |
@@ -1,8 +0,9 @@ | ||
# RXjs Subscription manager | ||
This does hopefully make subscription management less tedious, and helps clean up your code with less variables. | ||
# RXJS Subscription manager | ||
This does hopefully make subscription management less tedious, and helps clean up your code with fewer variables and | ||
fewer lines of repeated code. | ||
You can install it like this:``npm i --save @ukon1990/subscription-manager`` | ||
Originally this code base were written before I found out about the | ||
basic ``subscription.add()``, but then you need to write more code manually. But i still find this method preferable, | ||
Originally this code base was written before I found out about the | ||
basic ``subscription.add()``, but then you need to write more code manually. I still find this method preferable, | ||
for my use-cases. | ||
@@ -31,11 +32,9 @@ | ||
}); | ||
// Unsubscribe upon the first event. | ||
// but also makes sure that it is being unsubscribed as usual if no event is triggered | ||
this.subs.addSingleEvent( | ||
this.form.controls.firstName.valueChanges, | ||
(change) => this.onNameChange(change)); | ||
this.subs.add( | ||
this.form.controls.firstName.valueChanges, | ||
(change) => this.onNameChange(change), { | ||
// Unsubscribe upon the first event. | ||
// but also makes sure that it is being unsubscribed as usual if no event is triggered | ||
terminateUponEvent: true | ||
}); | ||
this.subs.add( | ||
this.form.controls.surname.valueChanges, | ||
@@ -106,9 +105,9 @@ (change) => this.onNameChange(change), { | ||
There is also not less repeatable code hopefully. | ||
The SubscriptionManager should hopefully reduce unnecessary repeated code, for these kinds of things. | ||
You don't need to do valueChanges.subscribe, and you don't need to add a pipe and takeWhile/Until and all that, if you | ||
just want the subscription to terminate upon the first event. | ||
just want the subscription to terminate upon the first event. You can just use the addSingleEvent function instead of the add function. | ||
You can also get subscription manager to return the list or map of the subscriptions with ``.getMap()`` or ``.getList()``. | ||
You can also get subscription manager to return the list or map of the subscriptions with ``.getMap()``(only those whom have an ID) or ``.getList()``. | ||
If you want, you can also do add the ``.pipe(takeWhile(...logic...))`` if you want. |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
27212
0
112