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.17 to 0.0.0-beta.18

src/AggregateStream.d.ts

2

index.d.ts

@@ -7,1 +7,3 @@ export * from './src/DestroyEvent';

export * from './src/ReactivePromise';
export * from './src/StatefulStream';
export * from './src/ValueStream';

@@ -12,2 +12,4 @@ "use strict";

__export(require("./src/ReactivePromise"));
__export(require("./src/StatefulStream"));
__export(require("./src/ValueStream"));
//# sourceMappingURL=index.js.map

4

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

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

},
"gitHead": "ca1636ae2e6347d6aeb9c2911e168e2539dcbc6a"
"gitHead": "6349c6686dbb291301ac4d97c7b29e5d48ac5b60"
}
# FireRx
RxJS on steroids. Makes subjects behave like promises to support async/await and adds new useful classes.
RxJS on steroids. Adds memory safety and garbage collection features to work with subjects and subscriptions.
Adds streams that behave both like subjects behave and promises to support async/await.
## StatefulSubject
StatefulSubject extends ReplaySubject from RxJS and adds Promise interface so that you can use async/await operators on it.
StatefulSubject extends ReplaySubject from RxJS and adds memory safety and garbage collection.
```typescript

@@ -12,3 +13,14 @@ import { StatefulSubject } from '@typeheim/fire-rx'

subject.next(5)
subject.next(5) // emits to all subscriptions 5
subject.stop() // completes subject and unsubscribe all subscriptions
```
## StatefulStream
StatefulStream extends StatefulSubject and adds Promise interface so that you can use async/await operators on it.
```typescript
import { StatefulStream } from '@typeheim/fire-rx'
let subject = new StatefulStream<number>(1)
subject.next(5)
await subject // returns 5

@@ -18,6 +30,8 @@

await subject // returns 6
subject.stop() // completes subject and unsubscribe all subscriptions
```
## ValueSubject
ValueSubject extends BehaviorSubject from RxJS and adds Promise interface so that you can use async/await operators on it.
ValueSubject extends BehaviorSubject from RxJS and adds memory safety and garbage collection.
```typescript

@@ -28,2 +42,14 @@ import { ValueSubject } from '@typeheim/fire-rx'

subject.next(5) // emits to all subscriptions 5
subject.stop() // completes subject and unsubscribe all subscriptions
```
## ValueStream
ValueStream extends ValueSubject from RxJS and adds Promise interface so that you can use async/await operators on it.
```typescript
import { ValueStream } from '@typeheim/fire-rx'
let subject = new ValueStream<number>(0)
subject.next(5)

@@ -30,0 +56,0 @@ await subject // returns 5

@@ -24,4 +24,9 @@ "use strict";

this.next(true);
this.complete();
if (!this.isStopped) {
this.complete();
}
this.hub.unsubscribe();
if (!this.closed) {
this.unsubscribe();
}
}

@@ -28,0 +33,0 @@ }

import { ReplaySubject } from 'rxjs';
import { Subscribable } from './contracts';
import { SubscriptionsHub } from './SubscriptionsHub';
export declare class StatefulSubject<T> extends ReplaySubject<T> implements PromiseLike<T> {
protected _internalPromise: Promise<T>;
export declare class StatefulSubject<T> extends ReplaySubject<T> {
protected _emitsCount: number;
protected hub: SubscriptionsHub;
get emitsCount(): number;
get subscriptionsCount(): number;
next(value?: T): void;
protected get internalPromise(): Promise<T>;
/**

@@ -21,29 +20,13 @@ * @deprecated internal method

/**
* @deprecated
*/
until(destroyEvent: Subscribable<any>): this;
/**
* Completes subject and clean up resources
*/
close(): void;
stop(): void;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
* Completes subject with error and unsubscribe all subscriptions
*/
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
fail(error: any): void;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
* @deprecated
*/
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
/**
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
* resolved value cannot be modified from the callback.
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
* @returns A Promise for the completion of the callback.
*/
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
close(): void;
}

@@ -14,2 +14,5 @@ "use strict";

}
get subscriptionsCount() {
return this.hub.count;
}
next(value) {

@@ -19,30 +22,2 @@ this._emitsCount++;

}
get internalPromise() {
if (!this._internalPromise) {
// in order for promise to properly return values from subject, it's required to "resolve" each "next" value
// and to keep behavior consistent, there's a storage variable "lastValue" that will be resolved on subject completion
let lastValue = null;
this._internalPromise = new Promise((resolve, reject) => {
this.subscribe({
next: (data) => {
lastValue = data;
// promise should return only one value and then being destroyed
this._internalPromise = null;
resolve(data);
},
error: (error) => {
// promise should return only one value and then being destroyed
this._internalPromise = null;
reject(error);
},
complete: () => {
// promise should return only one value and then being destroyed
this._internalPromise = null;
resolve(lastValue);
},
});
});
}
return this._internalPromise;
}
/**

@@ -62,3 +37,3 @@ * @deprecated internal method

destroyEvent.subscribe(() => {
this.close();
this.stop();
});

@@ -68,43 +43,31 @@ return this;

/**
* @deprecated
*/
until(destroyEvent) {
return this.emitUntil(destroyEvent);
}
/**
* Completes subject and clean up resources
*/
close() {
this._internalPromise = null;
this.complete();
stop() {
if (!this.isStopped) {
this.complete();
}
this.hub.unsubscribe();
if (!this.closed) {
this.unsubscribe();
}
}
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
* Completes subject with error and unsubscribe all subscriptions
*/
then(onfulfilled, onrejected) {
return this.internalPromise.then(onfulfilled);
fail(error) {
this.error(error);
this.hub.unsubscribe();
if (!this.closed) {
this.unsubscribe();
}
}
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
* @deprecated
*/
catch(onrejected) {
return this.internalPromise.catch(onrejected);
close() {
this.stop();
}
/**
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
* resolved value cannot be modified from the callback.
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
* @returns A Promise for the completion of the callback.
*/
finally(onfinally) {
return this.internalPromise.finally(onfinally);
}
}
exports.StatefulSubject = StatefulSubject;
//# sourceMappingURL=StatefulSubject.js.map
import { BehaviorSubject, Subscribable } from 'rxjs';
import { SubscriptionsHub } from './SubscriptionsHub';
export declare class ValueSubject<T> extends BehaviorSubject<T> {
protected _internalPromise: Promise<T>;
protected _emitsCount: number;

@@ -9,3 +8,2 @@ protected hub: SubscriptionsHub;

next(value?: T): void;
protected get internalPromise(): Promise<T>;
/**

@@ -24,26 +22,11 @@ * @deprecated internal method

until(destroyEvent: Subscribable<any>): this;
stop(): void;
/**
* Completes subject and clean up resources
* Completes subject with error and unsubscribe all subscriptions
*/
close(): void;
fail(error: any): void;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
* @deprecated
*/
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
/**
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
* resolved value cannot be modified from the callback.
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
* @returns A Promise for the completion of the callback.
*/
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
close(): void;
}

@@ -18,30 +18,2 @@ "use strict";

}
get internalPromise() {
if (!this._internalPromise) {
// in order for promise to properly return values from subject, it's required to "resolve" each "next" value
// and to keep behavior consistent, there's a storage variable "lastValue" that will be resolved on subject completion
let lastValue = null;
this._internalPromise = new Promise((resolve, reject) => {
this.subscribe({
next: (data) => {
lastValue = data;
// promise should return only one value and then being destroyed
this._internalPromise = null;
resolve(data);
},
error: (error) => {
// promise should return only one value and then being destroyed
this._internalPromise = null;
reject(error);
},
complete: () => {
// promise should return only one value and then being destroyed
this._internalPromise = null;
resolve(lastValue);
},
});
});
}
return this._internalPromise;
}
/**

@@ -61,3 +33,3 @@ * @deprecated internal method

destroyEvent.subscribe(() => {
this.close();
this.stop();
});

@@ -72,38 +44,29 @@ return this;

}
/**
* Completes subject and clean up resources
*/
close() {
this._internalPromise = null;
this.complete();
stop() {
if (!this.isStopped) {
this.complete();
}
this.hub.unsubscribe();
if (!this.closed) {
this.unsubscribe();
}
}
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
* Completes subject with error and unsubscribe all subscriptions
*/
then(onfulfilled, onrejected) {
return this.internalPromise.then(onfulfilled);
fail(error) {
this.error(error);
this.hub.unsubscribe();
if (!this.closed) {
this.unsubscribe();
}
}
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
* @deprecated
*/
catch(onrejected) {
return this.internalPromise.catch(onrejected);
close() {
this.stop();
}
/**
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
* resolved value cannot be modified from the callback.
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
* @returns A Promise for the completion of the callback.
*/
finally(onfinally) {
return this.internalPromise.finally(onfinally);
}
}
exports.ValueSubject = ValueSubject;
//# sourceMappingURL=ValueSubject.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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