Comparing version 1.0.5 to 1.0.6
@@ -1,2 +0,2 @@ | ||
import { Subject, Subscription } from "rxjs"; | ||
import { Subscription, Observable } from "rxjs"; | ||
import { observedObjects } from "./observedObjectsSymbol"; | ||
@@ -17,3 +17,3 @@ export declare type ObservableObjectType<T> = _ObservableObject<T> & T; | ||
*/ | ||
observe<A = any>(prop: string): Subject<A>; | ||
observe<A = any>(prop: string): Observable<A>; | ||
/** | ||
@@ -20,0 +20,0 @@ * Unsubscribes from all the subscriptions in a specific pool |
14
index.js
@@ -6,12 +6,2 @@ "use strict"; | ||
const observedObjectsSymbol_1 = require("./observedObjectsSymbol"); | ||
/** | ||
* A Subject that will only memorize its subscribers | ||
* And remove them on unsubscribe. | ||
* Unsubscription will not close or stop the Subject itself. | ||
*/ | ||
class ReusableSubject extends rxjs_1.Subject { | ||
unsubscribe() { | ||
this.observers = []; | ||
} | ||
} | ||
class _ObservableObject { | ||
@@ -119,5 +109,5 @@ constructor(from = {}, optHandlers = {}) { | ||
if (!this[observedObjectsSymbol_1.observedObjects][prop]) { | ||
this[observedObjectsSymbol_1.observedObjects][prop] = new ReusableSubject(); | ||
this[observedObjectsSymbol_1.observedObjects][prop] = new rxjs_1.Subject(); | ||
} | ||
return this[observedObjectsSymbol_1.observedObjects][prop]; | ||
return this[observedObjectsSymbol_1.observedObjects][prop].asObservable(); | ||
} | ||
@@ -124,0 +114,0 @@ /** |
{ | ||
"name": "roxe", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Observe object changes through proxies", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -107,3 +107,3 @@ # Roxe | ||
```typescript | ||
observableObject.observe<A = any>(prop: string): Subject<A>; | ||
observableObject.observe<A = any>(prop: string): Observable<A>; | ||
``` | ||
@@ -113,5 +113,3 @@ | ||
Use this method to register a Subject to subscribe to. | ||
To avoid confusion between Subject `.unsubscribe` and Subscription `.unsubscribe`, the returned Subject will unsubscribe only the registered `Subscriptions` without closing/stopping the Subject, even if (I know...), Subject shouldn't be reusable. | ||
Use this method to create an Observable to which you can subscribe to. | ||
This methods accepts a generic type `A` that will be passed to the creation of the Subject. | ||
@@ -123,3 +121,3 @@ | ||
`Subject<A>` | ||
`Observable<A>` | ||
@@ -205,3 +203,3 @@ <br> | ||
This project compiles to a `CommonJS` module as the original project this comes from (see below), used Webpack, which does not digest `UMD` modules (using some loaders was breaking the debugging process for some reasons). If you'll need to get the UMD version,, I have prepared an npm script to achieve this. Follow the script below: | ||
This project compiles to a `CommonJS` module as the original project this comes from (see below), used Webpack, which does not digest `UMD` modules (using some loaders was breaking the debugging process for some reasons). If you'll need to get the UMD version, I have prepared an npm script to achieve this. Follow the script below: | ||
@@ -208,0 +206,0 @@ ```sh |
58739
427
223