refactor(EventEmitter): rename .next() to .emit()
BREAKING CHANGE: EventEmitter#next(value) is deprecated, use EventEmitter#emit(value) instead. Closes #4287 Closes #5302
This commit is contained in:
@@ -46,9 +46,14 @@ class ObservableWrapper {
|
||||
s.cancel();
|
||||
}
|
||||
|
||||
@Deprecated('Use callEmit() instead')
|
||||
static void callNext(EventEmitter emitter, value) {
|
||||
emitter.add(value);
|
||||
}
|
||||
|
||||
static void callEmit(EventEmitter emitter, value) {
|
||||
emitter.add(value);
|
||||
}
|
||||
|
||||
static void callError(EventEmitter emitter, error) {
|
||||
emitter.addError(error);
|
||||
@@ -85,6 +90,10 @@ class EventEmitter<T> extends Stream<T> {
|
||||
void add(value) {
|
||||
_controller.add(value);
|
||||
}
|
||||
|
||||
void emit(value) {
|
||||
_controller.add(value);
|
||||
}
|
||||
|
||||
void addError(error) {
|
||||
_controller.addError(error);
|
||||
|
||||
@@ -39,8 +39,13 @@ export class ObservableWrapper {
|
||||
|
||||
static dispose(subscription: any) { subscription.unsubscribe(); }
|
||||
|
||||
/**
|
||||
* @deprecated - use callEmit() instead
|
||||
*/
|
||||
static callNext(emitter: EventEmitter<any>, value: any) { emitter.next(value); }
|
||||
|
||||
static callEmit(emitter: EventEmitter<any>, value: any) { emitter.emit(value); }
|
||||
|
||||
static callError(emitter: EventEmitter<any>, error: any) { emitter.error(error); }
|
||||
|
||||
static callComplete(emitter: EventEmitter<any>) { emitter.complete(); }
|
||||
@@ -78,9 +83,9 @@ export class ObservableWrapper {
|
||||
* toggle() {
|
||||
* this.visible = !this.visible;
|
||||
* if (this.visible) {
|
||||
* this.open.next(null);
|
||||
* this.open.emit(null);
|
||||
* } else {
|
||||
* this.close.next(null);
|
||||
* this.close.emit(null);
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
@@ -104,6 +109,13 @@ export class EventEmitter<T> extends Subject<T> {
|
||||
this._isAsync = isAsync;
|
||||
}
|
||||
|
||||
emit(value: T) { super.next(value); }
|
||||
|
||||
/**
|
||||
* @deprecated - use .emit(value) instead
|
||||
*/
|
||||
next(value: any) { super.next(value); }
|
||||
|
||||
subscribe(generatorOrNext?: any, error?: any, complete?: any): any {
|
||||
if (generatorOrNext && typeof generatorOrNext === 'object') {
|
||||
let schedulerFn = this._isAsync ?
|
||||
|
||||
Reference in New Issue
Block a user