Class: BehaviorSubject<T>
Defined in: node_modules/rxjs/dist/types/internal/BehaviorSubject.d.ts:6
A variant of Subject that requires an initial value and emits its current value whenever it is subscribed to.
Extends
Subject<T>
Extended by
Type Parameters
T
T
Constructors
Constructor
new BehaviorSubject<
T>(_value):BehaviorSubject<T>
Defined in: node_modules/rxjs/dist/types/internal/BehaviorSubject.d.ts:8
Parameters
_value
T
Returns
BehaviorSubject<T>
Overrides
Properties
closed
closed:
boolean
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:12
Inherited from
hasError
hasError:
boolean
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:19
Deprecated
Internal implementation detail, do not use directly. Will be made internal in v8.
Inherited from
isStopped
isStopped:
boolean
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:17
Deprecated
Internal implementation detail, do not use directly. Will be made internal in v8.
Inherited from
observers
observers:
Observer<T>[]
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:15
Deprecated
Internal implementation detail, do not use directly. Will be made internal in v8.
Inherited from
operator
operator:
Operator<any,T> |undefined
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:17
Deprecated
Internal implementation detail, do not use directly. Will be made internal in v8.
Inherited from
source
source:
Observable<any> |undefined
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:13
Deprecated
Internal implementation detail, do not use directly. Will be made internal in v8.
Inherited from
thrownError
thrownError:
any
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:21
Deprecated
Internal implementation detail, do not use directly. Will be made internal in v8.
Inherited from
create()
staticcreate: (...args) =>any
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:27
Creates a "subject" by basically gluing an observer to an observable.
Parameters
args
...any[]
Returns
any
Deprecated
Recommended you do not use. Will be removed at some point in the future. Plans for replacement still under discussion.
Inherited from
Accessors
observed
Get Signature
get observed():
boolean
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:35
Returns
boolean
Inherited from
value
Get Signature
get value():
T
Defined in: node_modules/rxjs/dist/types/internal/BehaviorSubject.d.ts:9
Returns
T
Methods
asObservable()
asObservable():
Observable<T>
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:42
Creates a new Observable with this Subject as the source. You can do this to create custom Observer-side logic of the Subject and conceal it from code that uses the Observable.
Returns
Observable<T>
Observable that this Subject casts to.
Inherited from
complete()
complete():
void
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:33
Returns
void
Inherited from
error()
error(
err):void
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:32
Parameters
err
any
Returns
void
Inherited from
forEach()
Call Signature
forEach(
next):Promise<void>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:90
Used as a NON-CANCELLABLE means of subscribing to an observable, for use with APIs that expect promises, like async/await. You cannot unsubscribe from this.
WARNING: Only use this with observables you know will complete. If the source observable does not complete, you will end up with a promise that is hung up, and potentially all of the state of an async function hanging out in memory. To avoid this situation, look into adding something like timeout, take, takeWhile, or takeUntil amongst others.
Example
import { interval, take } from 'rxjs';
const source$ = interval(1000).pipe(take(4));
async function getTotal() {
let total = 0;
await source$.forEach(value => {
total += value;
console.log('observable -> ' + value);
});
return total;
}
getTotal().then(
total => console.log('Total: ' + total)
);
// Expected:
// 'observable -> 0'
// 'observable -> 1'
// 'observable -> 2'
// 'observable -> 3'
// 'Total: 6'Parameters
next
(value) => void
A handler for each value emitted by the observable.
Returns
Promise<void>
A promise that either resolves on observable completion or rejects with the handled error.
Inherited from
Call Signature
forEach(
next,promiseCtor):Promise<void>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:102
Parameters
next
(value) => void
a handler for each value emitted by the observable
promiseCtor
PromiseConstructorLike
a constructor function used to instantiate the Promise
Returns
Promise<void>
a promise that either resolves on observable completion or rejects with the handled error
Deprecated
Passing a Promise constructor will no longer be available in upcoming versions of RxJS. This is because it adds weight to the library, for very little benefit. If you need this functionality, it is recommended that you either polyfill Promise, or you create an adapter to convert the returned native promise to whatever promise implementation you wanted. Will be removed in v8.
Inherited from
getValue()
getValue():
T
Defined in: node_modules/rxjs/dist/types/internal/BehaviorSubject.d.ts:10
Returns
T
lift()
lift<
R>(operator):Observable<R>
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:30
Type Parameters
R
R
Parameters
operator
Operator<T, R>
Returns
Observable<R>
Deprecated
Internal implementation detail, do not use directly. Will be made internal in v8.
Inherited from
next()
next(
value):void
Defined in: node_modules/rxjs/dist/types/internal/BehaviorSubject.d.ts:11
Parameters
value
T
Returns
void
Overrides
pipe()
Call Signature
pipe():
Observable<T>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:103
Returns
Observable<T>
Inherited from
Call Signature
pipe<
A>(op1):Observable<A>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:104
Type Parameters
A
A
Parameters
op1
OperatorFunction<T, A>
Returns
Observable<A>
Inherited from
Call Signature
pipe<
A,B>(op1,op2):Observable<B>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:105
Type Parameters
A
A
B
B
Parameters
op1
OperatorFunction<T, A>
op2
OperatorFunction<A, B>
Returns
Observable<B>
Inherited from
Call Signature
pipe<
A,B,C>(op1,op2,op3):Observable<C>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:106
Type Parameters
A
A
B
B
C
C
Parameters
op1
OperatorFunction<T, A>
op2
OperatorFunction<A, B>
op3
OperatorFunction<B, C>
Returns
Observable<C>
Inherited from
Call Signature
pipe<
A,B,C,D>(op1,op2,op3,op4):Observable<D>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:107
Type Parameters
A
A
B
B
C
C
D
D
Parameters
op1
OperatorFunction<T, A>
op2
OperatorFunction<A, B>
op3
OperatorFunction<B, C>
op4
OperatorFunction<C, D>
Returns
Observable<D>
Inherited from
Call Signature
pipe<
A,B,C,D,E>(op1,op2,op3,op4,op5):Observable<E>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:108
Type Parameters
A
A
B
B
C
C
D
D
E
E
Parameters
op1
OperatorFunction<T, A>
op2
OperatorFunction<A, B>
op3
OperatorFunction<B, C>
op4
OperatorFunction<C, D>
op5
OperatorFunction<D, E>
Returns
Observable<E>
Inherited from
Call Signature
pipe<
A,B,C,D,E,F>(op1,op2,op3,op4,op5,op6):Observable<F>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:109
Type Parameters
A
A
B
B
C
C
D
D
E
E
F
F
Parameters
op1
OperatorFunction<T, A>
op2
OperatorFunction<A, B>
op3
OperatorFunction<B, C>
op4
OperatorFunction<C, D>
op5
OperatorFunction<D, E>
op6
OperatorFunction<E, F>
Returns
Observable<F>
Inherited from
Call Signature
pipe<
A,B,C,D,E,F,G>(op1,op2,op3,op4,op5,op6,op7):Observable<G>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:110
Type Parameters
A
A
B
B
C
C
D
D
E
E
F
F
G
G
Parameters
op1
OperatorFunction<T, A>
op2
OperatorFunction<A, B>
op3
OperatorFunction<B, C>
op4
OperatorFunction<C, D>
op5
OperatorFunction<D, E>
op6
OperatorFunction<E, F>
op7
OperatorFunction<F, G>
Returns
Observable<G>
Inherited from
Call Signature
pipe<
A,B,C,D,E,F,G,H>(op1,op2,op3,op4,op5,op6,op7,op8):Observable<H>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:111
Type Parameters
A
A
B
B
C
C
D
D
E
E
F
F
G
G
H
H
Parameters
op1
OperatorFunction<T, A>
op2
OperatorFunction<A, B>
op3
OperatorFunction<B, C>
op4
OperatorFunction<C, D>
op5
OperatorFunction<D, E>
op6
OperatorFunction<E, F>
op7
OperatorFunction<F, G>
op8
OperatorFunction<G, H>
Returns
Observable<H>
Inherited from
Call Signature
pipe<
A,B,C,D,E,F,G,H,I>(op1,op2,op3,op4,op5,op6,op7,op8,op9):Observable<I>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:112
Type Parameters
A
A
B
B
C
C
D
D
E
E
F
F
G
G
H
H
I
I
Parameters
op1
OperatorFunction<T, A>
op2
OperatorFunction<A, B>
op3
OperatorFunction<B, C>
op4
OperatorFunction<C, D>
op5
OperatorFunction<D, E>
op6
OperatorFunction<E, F>
op7
OperatorFunction<F, G>
op8
OperatorFunction<G, H>
op9
OperatorFunction<H, I>
Returns
Observable<I>
Inherited from
Call Signature
pipe<
A,B,C,D,E,F,G,H,I>(op1,op2,op3,op4,op5,op6,op7,op8,op9, ...operations):Observable<unknown>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:113
Type Parameters
A
A
B
B
C
C
D
D
E
E
F
F
G
G
H
H
I
I
Parameters
op1
OperatorFunction<T, A>
op2
OperatorFunction<A, B>
op3
OperatorFunction<B, C>
op4
OperatorFunction<C, D>
op5
OperatorFunction<D, E>
op6
OperatorFunction<E, F>
op7
OperatorFunction<F, G>
op8
OperatorFunction<G, H>
op9
OperatorFunction<H, I>
operations
...OperatorFunction<any, any>[]
Returns
Observable<unknown>
Inherited from
subscribe()
Call Signature
subscribe(
observerOrNext?):Subscription
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:43
Parameters
observerOrNext?
Partial<Observer<T>> | (value) => void
Returns
Inherited from
Call Signature
subscribe(
next?,error?,complete?):Subscription
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:45
Parameters
next?
(value) => void | null
error?
(error) => void | null
complete?
() => void | null
Returns
Deprecated
Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments
Inherited from
toPromise()
Call Signature
toPromise():
Promise<T|undefined>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:115
Returns
Promise<T | undefined>
Deprecated
Replaced with firstValueFrom and lastValueFrom. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise
Inherited from
Call Signature
toPromise(
PromiseCtor):Promise<T|undefined>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:117
Parameters
PromiseCtor
PromiseConstructor
Returns
Promise<T | undefined>
Deprecated
Replaced with firstValueFrom and lastValueFrom. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise
Inherited from
Call Signature
toPromise(
PromiseCtor):Promise<T|undefined>
Defined in: node_modules/rxjs/dist/types/internal/Observable.d.ts:119
Parameters
PromiseCtor
PromiseConstructorLike
Returns
Promise<T | undefined>
Deprecated
Replaced with firstValueFrom and lastValueFrom. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise
Inherited from
unsubscribe()
unsubscribe():
void
Defined in: node_modules/rxjs/dist/types/internal/Subject.d.ts:34
Returns
void