-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
fix: use untracked internally for signal state stream
1 parent
54bfc1a
commit 0a67567
Showing
5 changed files
with
33 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { MonoTypeOperatorFunction, Observable } from 'rxjs'; | ||
|
||
export function ɵwrapObserverCalls<TValue>( | ||
invokeFn: (fn: () => void) => void | ||
): MonoTypeOperatorFunction<TValue> { | ||
return (source: Observable<TValue>) => { | ||
return new Observable<TValue>(subscriber => { | ||
return source.subscribe({ | ||
next(value) { | ||
invokeFn(() => subscriber.next(value)); | ||
}, | ||
error(error) { | ||
invokeFn(() => subscriber.error(error)); | ||
}, | ||
complete() { | ||
invokeFn(() => subscriber.complete()); | ||
} | ||
}); | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,10 @@ | ||
import { MonoTypeOperatorFunction, Observable, Observer } from 'rxjs'; | ||
import { ɵwrapObserverCalls } from '@ngxs/store/internals'; | ||
import { NgxsExecutionStrategy } from '../execution/symbols'; | ||
|
||
/** | ||
* Returns operator that will run | ||
* `subscribe` outside of the ngxs execution context | ||
*/ | ||
export function leaveNgxs<T>( | ||
ngxsExecutionStrategy: NgxsExecutionStrategy | ||
): MonoTypeOperatorFunction<T> { | ||
return (source: Observable<T>) => { | ||
return new Observable((sink: Observer<T>) => { | ||
return source.subscribe({ | ||
next(value) { | ||
ngxsExecutionStrategy.leave(() => sink.next(value)); | ||
}, | ||
error(error) { | ||
ngxsExecutionStrategy.leave(() => sink.error(error)); | ||
}, | ||
complete() { | ||
ngxsExecutionStrategy.leave(() => sink.complete()); | ||
} | ||
}); | ||
}); | ||
}; | ||
export function leaveNgxs<T>(ngxsExecutionStrategy: NgxsExecutionStrategy) { | ||
return ɵwrapObserverCalls<T>(fn => ngxsExecutionStrategy.leave(fn)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters