本文整理匯總了TypeScript中rxjs.BehaviorSubject.next方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript BehaviorSubject.next方法的具體用法?TypeScript BehaviorSubject.next怎麽用?TypeScript BehaviorSubject.next使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rxjs.BehaviorSubject
的用法示例。
在下文中一共展示了BehaviorSubject.next方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('depends on both isExecuting and canExecute', (done) => {
const canExecuteInput = new BehaviorSubject(true);
const canExecute = new BehaviorSubject(false);
const cmd = new ReactiveCommand(testOwner, x => {
canExecute.value.should.be.false;
return true;
}, canExecuteInput);
cmd.canExecute.subscribe(canExecute);
canExecute.value.should.be.true;
canExecuteInput.next(false);
canExecute.value.should.be.false;
canExecuteInput.next(true);
canExecute.value.should.be.true;
cmd.results.subscribe(x => {
canExecute.value.should.be.true;
done();
});
cmd.execute();
});
示例2: it
it('can buffer stream events while paused', () => {
const source = new Subject();
const sink = new BehaviorSubject(0);
let count = 0;
const pauser = new BehaviorSubject(false);
source
.pausableBuffer(pauser)
.do(() => { ++count; })
.subscribe(sink);
sink.value.should.eql(0);
source.next(1);
sink.value.should.eql(1);
count.should.eql(1);
pauser.next(true);
source.next(2);
sink.value.should.eql(1);
count.should.eql(1);
source.next(3);
sink.value.should.eql(1);
count.should.eql(1);
pauser.next(false);
sink.value.should.eql(3);
count.should.eql(3);
});
示例3: tap
tap(r => {
this.dataStore.allNotes.push(r.data);
this._allNotes.next([...this.dataStore.allNotes]);
this.dataStore.myNotes.push(r.data);
this._myNotes.next([...this.dataStore.myNotes]);
this.downloadContributions();
}),
示例4:
.subscribe((value)=>{
console.log(value);
this.filters.next({
...this.filters.value,
...value
})
})
示例5: test
test('re-validate config when updated', async () => {
const config$ = new BehaviorSubject(new ObjectToConfigAdapter({ key: 'value' }));
const configService = new ConfigService(config$, defaultEnv, logger);
configService.setSchema('key', schema.string());
const valuesReceived: any[] = [];
await configService.atPath('key').subscribe(
value => {
valuesReceived.push(value);
},
error => {
valuesReceived.push(error);
}
);
config$.next(new ObjectToConfigAdapter({ key: 123 }));
await expect(valuesReceived).toMatchInlineSnapshot(`
Array [
"value",
[Error: [key]: expected value of type [string] but got [number]],
]
`);
});
示例6: it
it("should filter higher order observables", async t => {
const input = [new BehaviorSubject(3), new BehaviorSubject(4), new BehaviorSubject(5), new BehaviorSubject(6)];
const origin = new ObservableArray(input);
const computed = origin.filterx(number$ => number$.pipe(map(n => n % 2 === 0)));
let output: BehaviorSubject<number>[] = [];
computed.subscribe(x => output = x);
t.is(output.length, 2);
t.deepEqual(output[0], input[1]);
input[0].next(2);
t.is(output.length, 3);
t.deepEqual(output[0], input[0]);
const o$ = new BehaviorSubject(8);
origin.unshift(o$);
t.is(output.length, 4);
t.deepEqual(output[0], o$);
o$.next(9);
t.is(output.length, 3);
t.deepEqual(output[0], input[0]);
});
示例7: resolve
.subscribe((response: any) => {
this.factorData = response;
console.log("data get by Id", this.factorData)
this.onDataChanged.next(this.factorData);
resolve(response);
}, reject);
示例8: setState
public setState( updater: any ) : void {
var currentState = this.getSnapshot();
// If the updater is a function, then it will need the current state in order to
// generate the next state. Otherwise, the updater is the Partial<T> object.
// --
// NOTE: There's no need for try/catch here since the updater() function will
// fail before the internal state is updated (if it has a bug in it). As such, it
// will naturally push the error-handling to the calling context, which makes
// sense for this type of workflow.
var partialState = ( updater instanceof Function )
? updater( currentState )
: updater
;
// If the updater function returned undefined, then it decided that no state
// needed to be changed. In that case, just return-out.
if ( partialState === undefined ) {
return;
}
var nextState = Object.assign( {}, currentState, partialState );
this.stateSubject.next( nextState );
}
示例9: deselectTodos
/**
* Deselect todos
*/
deselectTodos(): void
{
this.selectedTodos = [];
// Trigger the next event
this.onSelectedTodosChanged.next(this.selectedTodos);
}