Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@typeheim/fire-rx

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typeheim/fire-rx - npm Package Compare versions

Comparing version 0.0.0-beta.15 to 0.0.0-beta.16

4

package.json
{
"name": "@typeheim/fire-rx",
"version": "0.0.0-beta.15",
"version": "0.0.0-beta.16",
"description": "Firebase authentication library",

@@ -32,3 +32,3 @@ "keywords": [

},
"gitHead": "7773a9c68d67290db626045877eb20990982b99f"
"gitHead": "175283382a85817e53cd6f463a5784c736a5c130"
}

@@ -1,11 +0,26 @@

#FireRx
# FireRx
RxJS extension that provides async capabilities to subjects
RxJS on steroids. Makes subjects behave like promises to support async/await and adds new useful classes.
## StatefulSubject
StatefulSubject extends ReplaySubject from RxJS and adds Promise interface so that you can use async/await operators on it.
```typescript
import { FireReplaySubject } from '@typeheim/fire-rx'
import { StatefulSubject } from '@typeheim/fire-rx'
let subject = new StatefulSubject<number>(1)
let subject = new FireReplaySubject<number>(1)
subject.next(5)
await subject // returns 5
subject.next(6)
await subject // returns 6
```
## ValueSubject
ValueSubject extends BehaviorSubject from RxJS and adds Promise interface so that you can use async/await operators on it.
```typescript
import { ValueSubject } from '@typeheim/fire-rx'
let subject = new ValueSubject<number>(0)
subject.next(5)

@@ -17,1 +32,72 @@ await subject // returns 5

```
## ReactivePromise
ReactivePromise acts as a regular Promise but additionally let you use `subscribe` and `pipe` methods. ReactivePromise, like
StatefulSubject, buffers resolved value and can distribute it to multiple subscribers.
ReactivePromise is memory-safe and unsubscribe subscriptions once it's resolved.
```typescript
import { ReactivePromise } from '@typeheim/fire-rx'
let promise = new ReactivePromise<number>()
promise.resolve(5)
await promise // returns 5
promise.subscribe(value => console.log(value)) // returns 5
//..............
let promise = new ReactivePromise<number>((resolve, reject) => {
resolve(5)
})
promise.subscribe(value => console.log(value)) // returns 5
```
## SubscriptionsHub
SubscriptionsHub represents a hub of subscriptions that let you massively unsubscribe them at once. It might be useful to trigger
at object destruction to free resources
```typescript
import { SubscriptionsHub, StatefulSubject } from '@typeheim/fire-rx'
class Sample {
protected hub: SubscriptionsHub = new SubscriptionsHub()
doSomething() {
let subject = new StatefulSubject<number>()
this.hub.add(subject.subscribe(data => console.log(data)))
}
onDestroy() {
this.hub.unsubscribe()
}
}
```
## DestroyEvent
DestroyEvent is a special reactive class that servers as a destruction notifier and can be used in pair with Fire subjects or
with SubscriptionsHub
```typescript
import { DestroyEvent, SubscriptionsHub, StatefulSubject } from '@typeheim/fire-rx'
class Sample {
protected destroyEvent: DestroyEvent = new DestroyEvent()
protected hub: SubscriptionsHub = new SubscriptionsHub(this.destroyEvent)
doSomething() {
let subject = new StatefulSubject<number>()
this.hub.add(subject.subscribe(data => console.log(data)))
let anotherSubject = new StatefulSubject<number>()
subject.until(this.destroyEvent).subscribe(data => console.log(data))
}
onDestroy() {
this.destroyEvent.emit()
}
}
```

@@ -1,2 +0,2 @@

import { ReplaySubject } from 'rxjs';
import { ReactivePromise } from './ReactivePromise';
/**

@@ -6,4 +6,4 @@ * Special type of subject that should be used in pair with `until` method of

*/
export declare class DestroyEvent extends ReplaySubject<boolean> {
export declare class DestroyEvent extends ReactivePromise<boolean> {
emit(): void;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const rxjs_1 = require("rxjs");
const ReactivePromise_1 = require("./ReactivePromise");
/**

@@ -8,7 +8,5 @@ * Special type of subject that should be used in pair with `until` method of

*/
class DestroyEvent extends rxjs_1.ReplaySubject {
class DestroyEvent extends ReactivePromise_1.ReactivePromise {
emit() {
this.next(true);
this.complete();
this.unsubscribe();
this.resolve(true);
}

@@ -15,0 +13,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc