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:
parent
929abb9aa3
commit
3fa287aae2
|
@ -276,6 +276,9 @@ var ObservableWrapper = {
|
|||
callNext: function(ob, val) {
|
||||
ob.fn(val);
|
||||
},
|
||||
callEmit: function(ob, val) {
|
||||
ob.fn(val);
|
||||
},
|
||||
|
||||
subscribe: function(ob, fn) {
|
||||
ob.fn = fn;
|
||||
|
|
|
@ -230,7 +230,7 @@ import {bootstrap} from 'angular2/web_worker/ui';
|
|||
var instance = bootstrap("loader.js");
|
||||
var bus = instance.bus;
|
||||
bus.initChannel("My Custom Channel");
|
||||
bus.to("My Custom Channel").next("hello from the UI");
|
||||
bus.to("My Custom Channel").emit("hello from the UI");
|
||||
```
|
||||
```TypeScript
|
||||
// background_index.ts, which is running on the WebWorker
|
||||
|
|
|
@ -117,7 +117,7 @@ export class NgControlName extends NgControl implements OnChanges,
|
|||
|
||||
viewToModelUpdate(newValue: any): void {
|
||||
this.viewModel = newValue;
|
||||
ObservableWrapper.callNext(this.update, newValue);
|
||||
ObservableWrapper.callEmit(this.update, newValue);
|
||||
}
|
||||
|
||||
get path(): string[] { return controlPath(this.name, this._parent); }
|
||||
|
|
|
@ -160,7 +160,7 @@ export class NgForm extends ControlContainer implements Form {
|
|||
}
|
||||
|
||||
onSubmit(): boolean {
|
||||
ObservableWrapper.callNext(this.ngSubmit, null);
|
||||
ObservableWrapper.callEmit(this.ngSubmit, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ export class NgFormControl extends NgControl implements OnChanges {
|
|||
|
||||
viewToModelUpdate(newValue: any): void {
|
||||
this.viewModel = newValue;
|
||||
ObservableWrapper.callNext(this.update, newValue);
|
||||
ObservableWrapper.callEmit(this.update, newValue);
|
||||
}
|
||||
|
||||
private _isControlChanged(changes: {[key: string]: any}): boolean {
|
||||
|
|
|
@ -157,7 +157,7 @@ export class NgFormModel extends ControlContainer implements Form,
|
|||
}
|
||||
|
||||
onSubmit(): boolean {
|
||||
ObservableWrapper.callNext(this.ngSubmit, null);
|
||||
ObservableWrapper.callEmit(this.ngSubmit, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,6 @@ export class NgModel extends NgControl implements OnChanges {
|
|||
|
||||
viewToModelUpdate(newValue: any): void {
|
||||
this.viewModel = newValue;
|
||||
ObservableWrapper.callNext(this.update, newValue);
|
||||
ObservableWrapper.callEmit(this.update, newValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,8 +128,8 @@ export abstract class AbstractControl {
|
|||
}
|
||||
|
||||
if (emitEvent) {
|
||||
ObservableWrapper.callNext(this._valueChanges, this._value);
|
||||
ObservableWrapper.callNext(this._statusChanges, this._status);
|
||||
ObservableWrapper.callEmit(this._valueChanges, this._value);
|
||||
ObservableWrapper.callEmit(this._statusChanges, this._status);
|
||||
}
|
||||
|
||||
if (isPresent(this._parent) && !onlySelf) {
|
||||
|
@ -185,7 +185,7 @@ export abstract class AbstractControl {
|
|||
this._status = this._calculateStatus();
|
||||
|
||||
if (emitEvent) {
|
||||
ObservableWrapper.callNext(this._statusChanges, this._status);
|
||||
ObservableWrapper.callEmit(this._statusChanges, this._status);
|
||||
}
|
||||
|
||||
if (isPresent(this._parent)) {
|
||||
|
|
|
@ -66,5 +66,5 @@ export class QueryList<T> {
|
|||
reset(res: T[]): void { this._results = res; }
|
||||
|
||||
/** @internal */
|
||||
notifyOnChanges(): void { this._emitter.next(this); }
|
||||
notifyOnChanges(): void { this._emitter.emit(this); }
|
||||
}
|
||||
|
|
|
@ -1321,8 +1321,8 @@ export var Input: InputFactory = makePropDecorator(InputMetadata);
|
|||
* @Output('everyFiveSeconds') five5Secs = new EventEmitter();
|
||||
*
|
||||
* constructor() {
|
||||
* setInterval(() => this.everySecond.next("event"), 1000);
|
||||
* setInterval(() => this.five5Secs.next("event"), 5000);
|
||||
* setInterval(() => this.everySecond.emit("event"), 1000);
|
||||
* setInterval(() => this.five5Secs.emit("event"), 5000);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
|
|
|
@ -496,8 +496,8 @@ export class DirectiveMetadata extends InjectableMetadata {
|
|||
* five5Secs = new EventEmitter();
|
||||
*
|
||||
* constructor() {
|
||||
* setInterval(() => this.everySecond.next("event"), 1000);
|
||||
* setInterval(() => this.five5Secs.next("event"), 5000);
|
||||
* setInterval(() => this.everySecond.emit("event"), 1000);
|
||||
* setInterval(() => this.five5Secs.emit("event"), 5000);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
|
@ -1047,8 +1047,8 @@ export class InputMetadata {
|
|||
* @Output('everyFiveSeconds') five5Secs = new EventEmitter();
|
||||
*
|
||||
* constructor() {
|
||||
* setInterval(() => this.everySecond.next("event"), 1000);
|
||||
* setInterval(() => this.five5Secs.next("event"), 5000);
|
||||
* setInterval(() => this.everySecond.emit("event"), 1000);
|
||||
* setInterval(() => this.five5Secs.emit("event"), 5000);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
|
|
|
@ -187,7 +187,7 @@ export class NgZone {
|
|||
|
||||
/** @internal */
|
||||
_notifyOnTurnStart(parentRun): void {
|
||||
parentRun.call(this._innerZone, () => { this._onTurnStartEvents.next(null); });
|
||||
parentRun.call(this._innerZone, () => { this._onTurnStartEvents.emit(null); });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,7 +216,7 @@ export class NgZone {
|
|||
|
||||
/** @internal */
|
||||
_notifyOnTurnDone(parentRun): void {
|
||||
parentRun.call(this._innerZone, () => { this._onTurnDoneEvents.next(null); });
|
||||
parentRun.call(this._innerZone, () => { this._onTurnDoneEvents.emit(null); });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -255,7 +255,7 @@ export class NgZone {
|
|||
|
||||
/** @internal */
|
||||
_notifyOnEventDone(): void {
|
||||
this.runOutsideAngular(() => { this._onEventDoneEvents.next(null); });
|
||||
this.runOutsideAngular(() => { this._onEventDoneEvents.emit(null); });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -440,7 +440,7 @@ export class NgZone {
|
|||
zone = zone.parent;
|
||||
}
|
||||
if (ObservableWrapper.hasSubscribers(this._onErrorEvents)) {
|
||||
ObservableWrapper.callNext(this._onErrorEvents, new NgZoneError(e, trace));
|
||||
ObservableWrapper.callEmit(this._onErrorEvents, new NgZoneError(e, trace));
|
||||
}
|
||||
if (isPresent(this._onErrorHandler)) {
|
||||
this._onErrorHandler(e, trace);
|
||||
|
|
|
@ -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 ?
|
||||
|
|
|
@ -19,7 +19,7 @@ export class SpyLocation implements Location {
|
|||
|
||||
path(): string { return this._path; }
|
||||
|
||||
simulateUrlPop(pathname: string) { ObservableWrapper.callNext(this._subject, {'url': pathname}); }
|
||||
simulateUrlPop(pathname: string) { ObservableWrapper.callEmit(this._subject, {'url': pathname}); }
|
||||
|
||||
prepareExternalUrl(url: string): string {
|
||||
if (url.length > 0 && !url.startsWith('/')) {
|
||||
|
|
|
@ -13,7 +13,7 @@ export class MockLocationStrategy extends LocationStrategy {
|
|||
|
||||
simulatePopState(url: string): void {
|
||||
this.internalPath = url;
|
||||
ObservableWrapper.callNext(this._subject, null);
|
||||
ObservableWrapper.callEmit(this._subject, null);
|
||||
}
|
||||
|
||||
path(): string { return this.internalPath; }
|
||||
|
@ -26,7 +26,7 @@ export class MockLocationStrategy extends LocationStrategy {
|
|||
}
|
||||
|
||||
simulateUrlPop(pathname: string): void {
|
||||
ObservableWrapper.callNext(this._subject, {'url': pathname});
|
||||
ObservableWrapper.callEmit(this._subject, {'url': pathname});
|
||||
}
|
||||
|
||||
pushState(ctx: any, title: string, path: string, query: string): void {
|
||||
|
|
|
@ -53,7 +53,7 @@ export class Location {
|
|||
var browserBaseHref = this.platformStrategy.getBaseHref();
|
||||
this._baseHref = stripTrailingSlash(stripIndexHtml(browserBaseHref));
|
||||
this.platformStrategy.onPopState(
|
||||
(_) => { ObservableWrapper.callNext(this._subject, {'url': this.path(), 'pop': true}); });
|
||||
(_) => { ObservableWrapper.callEmit(this._subject, {'url': this.path(), 'pop': true}); });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -241,7 +241,7 @@ export class Router {
|
|||
return PromiseWrapper.all(unsettledInstructions);
|
||||
}
|
||||
|
||||
private _emitNavigationFinish(url): void { ObservableWrapper.callNext(this._subject, url); }
|
||||
private _emitNavigationFinish(url): void { ObservableWrapper.callEmit(this._subject, url); }
|
||||
|
||||
private _afterPromiseFinishNavigating(promise: Promise<any>): Promise<any> {
|
||||
return PromiseWrapper.catchError(promise.then((_) => this._finishNavigating()), (err) => {
|
||||
|
|
|
@ -216,7 +216,7 @@ class UpgradeNg1ComponentAdapter implements OnChanges, DoCheck {
|
|||
}
|
||||
for (var j = 0; j < outputs.length; j++) {
|
||||
var emitter = this[outputs[j]] = new EventEmitter();
|
||||
this.setComponentProperty(outputs[j], ((emitter) => (value) => emitter.next(value))(emitter));
|
||||
this.setComponentProperty(outputs[j], ((emitter) => (value) => emitter.emit(value))(emitter));
|
||||
}
|
||||
for (var k = 0; k < propOuts.length; k++) {
|
||||
this[propOuts[k]] = new EventEmitter();
|
||||
|
@ -246,7 +246,7 @@ class UpgradeNg1ComponentAdapter implements OnChanges, DoCheck {
|
|||
// ignore because NaN != NaN
|
||||
} else {
|
||||
var eventEmitter: EventEmitter<any> = this[this.propOuts[i]];
|
||||
eventEmitter.next(lastValues[i] = value);
|
||||
eventEmitter.emit(lastValues[i] = value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ export class ClientMessageBroker_ extends ClientMessageBroker {
|
|||
if (id != null) {
|
||||
message['id'] = id;
|
||||
}
|
||||
ObservableWrapper.callNext(this._sink, message);
|
||||
ObservableWrapper.callEmit(this._sink, message);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
|
|
@ -125,9 +125,9 @@ export class PostMessageBusSource implements MessageBusSource {
|
|||
if (StringMapWrapper.contains(this._channels, channel)) {
|
||||
var channelInfo = this._channels[channel];
|
||||
if (channelInfo.runInZone) {
|
||||
this._zone.run(() => { channelInfo.emitter.next(data.message); });
|
||||
this._zone.run(() => { channelInfo.emitter.emit(data.message); });
|
||||
} else {
|
||||
channelInfo.emitter.next(data.message);
|
||||
channelInfo.emitter.emit(data.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ export class ServiceMessageBroker_ extends ServiceMessageBroker {
|
|||
|
||||
private _wrapWebWorkerPromise(id: string, promise: Promise<any>, type: Type): void {
|
||||
PromiseWrapper.then(promise, (result: any) => {
|
||||
ObservableWrapper.callNext(
|
||||
ObservableWrapper.callEmit(
|
||||
this._sink,
|
||||
{'type': 'result', 'value': this._serializer.serialize(result, type), 'id': id});
|
||||
});
|
||||
|
|
|
@ -101,7 +101,7 @@ export class EventDispatcher implements RenderEventDispatcher {
|
|||
var serializedLocals = StringMapWrapper.create();
|
||||
StringMapWrapper.set(serializedLocals, '$event', serializedEvent);
|
||||
|
||||
ObservableWrapper.callNext(this._sink, {
|
||||
ObservableWrapper.callEmit(this._sink, {
|
||||
"viewRef": this._serializer.serialize(this._viewRef, RenderViewRef),
|
||||
"elementIndex": elementIndex,
|
||||
"eventName": eventName,
|
||||
|
|
|
@ -20,7 +20,7 @@ export class WebWorkerSetup {
|
|||
|
||||
ObservableWrapper.subscribe(source, (message: string) => {
|
||||
if (StringWrapper.equals(message, "ready")) {
|
||||
ObservableWrapper.callNext(sink, {"rootUrl": this.rootUrl});
|
||||
ObservableWrapper.callEmit(sink, {"rootUrl": this.rootUrl});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ export function bootstrapWebWorkerCommon(
|
|||
ObservableWrapper.dispose(subscription);
|
||||
});
|
||||
|
||||
ObservableWrapper.callNext(bus.to(SETUP_CHANNEL), "ready");
|
||||
ObservableWrapper.callEmit(bus.to(SETUP_CHANNEL), "ready");
|
||||
return bootstrapProcess.promise;
|
||||
});
|
||||
return PromiseWrapper.then(appPromise, (app) => app.bootstrap(appComponentType));
|
||||
|
|
|
@ -990,7 +990,7 @@ class MyInput implements ControlValueAccessor {
|
|||
registerOnTouched(fn) {}
|
||||
|
||||
dispatchChangeEvent() {
|
||||
ObservableWrapper.callNext(this.onChange, this.value.substring(1, this.value.length - 1));
|
||||
ObservableWrapper.callEmit(this.onChange, this.value.substring(1, this.value.length - 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ export function main() {
|
|||
|
||||
function asyncValidatorReturningObservable(c) {
|
||||
var e = new EventEmitter();
|
||||
PromiseWrapper.scheduleMicrotask(() => ObservableWrapper.callNext(e, {"async": true}));
|
||||
PromiseWrapper.scheduleMicrotask(() => ObservableWrapper.callEmit(e, {"async": true}));
|
||||
return e;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,9 +101,9 @@ export function main() {
|
|||
var res = c.value != expected ? response : null;
|
||||
|
||||
PromiseWrapper.scheduleMicrotask(() => {
|
||||
ObservableWrapper.callNext(emitter, res);
|
||||
ObservableWrapper.callEmit(emitter, res);
|
||||
// this is required because of a bug in ObservableWrapper
|
||||
// where callComplete can fire before callNext
|
||||
// where callComplete can fire before callEmit
|
||||
// remove this one the bug is fixed
|
||||
TimerWrapper.setTimeout(() => { ObservableWrapper.callComplete(emitter); }, 0);
|
||||
});
|
||||
|
|
|
@ -46,7 +46,7 @@ export function main() {
|
|||
inject([AsyncTestCompleter], (async) => {
|
||||
pipe.transform(emitter);
|
||||
|
||||
ObservableWrapper.callNext(emitter, message);
|
||||
ObservableWrapper.callEmit(emitter, message);
|
||||
|
||||
TimerWrapper.setTimeout(() => {
|
||||
expect(pipe.transform(emitter)).toEqual(new WrappedValue(message));
|
||||
|
@ -58,7 +58,7 @@ export function main() {
|
|||
it("should return same value when nothing has changed since the last call",
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
pipe.transform(emitter);
|
||||
ObservableWrapper.callNext(emitter, message);
|
||||
ObservableWrapper.callEmit(emitter, message);
|
||||
|
||||
TimerWrapper.setTimeout(() => {
|
||||
pipe.transform(emitter);
|
||||
|
@ -75,7 +75,7 @@ export function main() {
|
|||
expect(pipe.transform(newEmitter)).toBe(null);
|
||||
|
||||
// this should not affect the pipe
|
||||
ObservableWrapper.callNext(emitter, message);
|
||||
ObservableWrapper.callEmit(emitter, message);
|
||||
|
||||
TimerWrapper.setTimeout(() => {
|
||||
expect(pipe.transform(newEmitter)).toBe(null);
|
||||
|
@ -86,7 +86,7 @@ export function main() {
|
|||
it("should request a change detection check upon receiving a new value",
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
pipe.transform(emitter);
|
||||
ObservableWrapper.callNext(emitter, message);
|
||||
ObservableWrapper.callEmit(emitter, message);
|
||||
|
||||
TimerWrapper.setTimeout(() => {
|
||||
expect(ref.spy('markForCheck')).toHaveBeenCalled();
|
||||
|
@ -103,7 +103,7 @@ export function main() {
|
|||
pipe.transform(emitter);
|
||||
pipe.onDestroy();
|
||||
|
||||
ObservableWrapper.callNext(emitter, message);
|
||||
ObservableWrapper.callEmit(emitter, message);
|
||||
|
||||
TimerWrapper.setTimeout(() => {
|
||||
expect(pipe.transform(emitter)).toBe(null);
|
||||
|
|
|
@ -32,7 +32,7 @@ export function main() {
|
|||
async.done();
|
||||
});
|
||||
|
||||
ObservableWrapper.callNext(emitter, 99);
|
||||
ObservableWrapper.callEmit(emitter, 99);
|
||||
}));
|
||||
|
||||
it("should call the throw callback", inject([AsyncTestCompleter], (async) => {
|
||||
|
@ -58,7 +58,7 @@ export function main() {
|
|||
var called = false;
|
||||
ObservableWrapper.subscribe(emitter, (value) => { called = true; });
|
||||
|
||||
ObservableWrapper.callNext(emitter, 99);
|
||||
ObservableWrapper.callEmit(emitter, 99);
|
||||
expect(called).toBe(false);
|
||||
});
|
||||
|
||||
|
@ -71,7 +71,7 @@ export function main() {
|
|||
async.done();
|
||||
});
|
||||
log.push(1);
|
||||
ObservableWrapper.callNext(e, 2);
|
||||
ObservableWrapper.callEmit(e, 2);
|
||||
log.push(3);
|
||||
}));
|
||||
|
||||
|
@ -80,7 +80,7 @@ export function main() {
|
|||
var log = [];
|
||||
ObservableWrapper.subscribe(e, (x) => { log.push(x); });
|
||||
log.push(1);
|
||||
ObservableWrapper.callNext(e, 2);
|
||||
ObservableWrapper.callEmit(e, 2);
|
||||
log.push(3);
|
||||
expect(log).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
|
|
@ -2016,7 +2016,7 @@ class DirectiveEmitingEvent {
|
|||
this.event = new EventEmitter();
|
||||
}
|
||||
|
||||
fireEvent(msg: string) { ObservableWrapper.callNext(this.event, msg); }
|
||||
fireEvent(msg: string) { ObservableWrapper.callEmit(this.event, msg); }
|
||||
}
|
||||
|
||||
@Directive({selector: '[update-host-attributes]', host: {'role': 'button'}})
|
||||
|
@ -2039,7 +2039,7 @@ class DirectiveUpdatingHostActions {
|
|||
|
||||
constructor() { this.setAttr = new EventEmitter(); }
|
||||
|
||||
triggerSetAttr(attrValue) { ObservableWrapper.callNext(this.setAttr, ["key", attrValue]); }
|
||||
triggerSetAttr(attrValue) { ObservableWrapper.callEmit(this.setAttr, ["key", attrValue]); }
|
||||
}
|
||||
|
||||
@Directive({selector: '[listener]', host: {'(event)': 'onEvent($event)'}})
|
||||
|
@ -2174,7 +2174,7 @@ class DirectiveWithTwoWayBinding {
|
|||
controlChange = new EventEmitter();
|
||||
control = null;
|
||||
|
||||
triggerChange(value) { ObservableWrapper.callNext(this.controlChange, value); }
|
||||
triggerChange(value) { ObservableWrapper.callEmit(this.controlChange, value); }
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
@ -2382,5 +2382,5 @@ class DirectiveWithPropDecorators {
|
|||
this.target = target;
|
||||
}
|
||||
|
||||
fireEvent(msg) { ObservableWrapper.callNext(this.event, msg); }
|
||||
fireEvent(msg) { ObservableWrapper.callEmit(this.event, msg); }
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ class MockNgZone extends NgZone {
|
|||
this._onEventDoneStream = new EventEmitter(false);
|
||||
}
|
||||
|
||||
start(): void { ObservableWrapper.callNext(this._onTurnStartStream, null); }
|
||||
start(): void { ObservableWrapper.callEmit(this._onTurnStartStream, null); }
|
||||
|
||||
finish(): void { ObservableWrapper.callNext(this._onEventDoneStream, null); }
|
||||
finish(): void { ObservableWrapper.callEmit(this._onEventDoneStream, null); }
|
||||
}
|
||||
|
||||
export function main() {
|
||||
|
|
|
@ -683,6 +683,7 @@ var NG_ALL = [
|
|||
*/
|
||||
'EventEmitter.mapTo():js',
|
||||
'EventEmitter.next():js',
|
||||
'EventEmitter.emit():js',
|
||||
'EventEmitter.materialize():js',
|
||||
'EventEmitter.merge():js',
|
||||
'EventEmitter.mergeAll():js',
|
||||
|
|
|
@ -404,7 +404,7 @@ function logHook(name: string, next: ComponentInstruction, prev: ComponentInstru
|
|||
var message = name + ': ' + (isPresent(prev) ? ('/' + prev.urlPath) : 'null') + ' -> ' +
|
||||
(isPresent(next) ? ('/' + next.urlPath) : 'null');
|
||||
log.push(message);
|
||||
ObservableWrapper.callNext(eventBus, message);
|
||||
ObservableWrapper.callEmit(eventBus, message);
|
||||
}
|
||||
|
||||
@Component({selector: 'activate-cmp'})
|
||||
|
|
|
@ -178,10 +178,10 @@ export function main() {
|
|||
assertChange('twoWayA', 'initModelA');
|
||||
assertChange('twoWayB', 'initModelB');
|
||||
|
||||
this.twoWayAEmitter.next('newA');
|
||||
this.twoWayBEmitter.next('newB');
|
||||
this.eventA.next('aFired');
|
||||
this.eventB.next('bFired');
|
||||
this.twoWayAEmitter.emit('newA');
|
||||
this.twoWayBEmitter.emit('newB');
|
||||
this.eventA.emit('aFired');
|
||||
this.eventB.emit('bFired');
|
||||
break;
|
||||
case 1:
|
||||
assertChange('twoWayA', 'newA');
|
||||
|
|
|
@ -37,7 +37,7 @@ export function main() {
|
|||
async.done();
|
||||
});
|
||||
var toEmitter = bus.to(CHANNEL);
|
||||
ObservableWrapper.callNext(toEmitter, MESSAGE);
|
||||
ObservableWrapper.callEmit(toEmitter, MESSAGE);
|
||||
}));
|
||||
|
||||
it("should broadcast", inject([AsyncTestCompleter], (async) => {
|
||||
|
@ -61,7 +61,7 @@ export function main() {
|
|||
}
|
||||
|
||||
var toEmitter = bus.to(CHANNEL);
|
||||
ObservableWrapper.callNext(toEmitter, MESSAGE);
|
||||
ObservableWrapper.callEmit(toEmitter, MESSAGE);
|
||||
}));
|
||||
|
||||
it("should keep channels independent", inject([AsyncTestCompleter], (async) => {
|
||||
|
@ -91,10 +91,10 @@ export function main() {
|
|||
});
|
||||
|
||||
var firstToEmitter = bus.to(CHANNEL_ONE);
|
||||
ObservableWrapper.callNext(firstToEmitter, MESSAGE_ONE);
|
||||
ObservableWrapper.callEmit(firstToEmitter, MESSAGE_ONE);
|
||||
|
||||
var secondToEmitter = bus.to(CHANNEL_TWO);
|
||||
ObservableWrapper.callNext(secondToEmitter, MESSAGE_TWO);
|
||||
ObservableWrapper.callEmit(secondToEmitter, MESSAGE_TWO);
|
||||
}));
|
||||
});
|
||||
|
||||
|
@ -121,7 +121,7 @@ export function main() {
|
|||
|
||||
var wasCalled = false;
|
||||
ObservableWrapper.subscribe(bus.from(CHANNEL), (message) => { wasCalled = true; });
|
||||
ObservableWrapper.callNext(bus.to(CHANNEL), "hi");
|
||||
ObservableWrapper.callEmit(bus.to(CHANNEL), "hi");
|
||||
|
||||
|
||||
flushMessages(() => {
|
||||
|
@ -141,7 +141,7 @@ export function main() {
|
|||
|
||||
var wasCalled = false;
|
||||
ObservableWrapper.subscribe(bus.from(CHANNEL), (message) => { wasCalled = true; });
|
||||
ObservableWrapper.callNext(bus.to(CHANNEL), "hi");
|
||||
ObservableWrapper.callEmit(bus.to(CHANNEL), "hi");
|
||||
|
||||
flushMessages(() => {
|
||||
expect(wasCalled).toBeTruthy();
|
||||
|
|
|
@ -10,7 +10,7 @@ export class MockEventEmitter<T> extends EventEmitter<T> {
|
|||
return new MockDisposable();
|
||||
}
|
||||
|
||||
next(value: any) { this._nextFns.forEach(fn => fn(value)); }
|
||||
emit(value: any) { this._nextFns.forEach(fn => fn(value)); }
|
||||
}
|
||||
|
||||
class MockDisposable {
|
||||
|
|
|
@ -53,7 +53,7 @@ export function main() {
|
|||
expect(arg1).toEqual(PASSED_ARG_1);
|
||||
expect(arg2).toEqual(PASSED_ARG_2);
|
||||
});
|
||||
ObservableWrapper.callNext(messageBuses.worker.to(CHANNEL),
|
||||
ObservableWrapper.callEmit(messageBuses.worker.to(CHANNEL),
|
||||
{'method': TEST_METHOD, 'args': [PASSED_ARG_1, PASSED_ARG_2]});
|
||||
}));
|
||||
|
||||
|
@ -63,7 +63,7 @@ export function main() {
|
|||
expect(arg1).toEqual(PASSED_ARG_1);
|
||||
return PromiseWrapper.wrap(() => { return RESULT; });
|
||||
});
|
||||
ObservableWrapper.callNext(messageBuses.worker.to(CHANNEL),
|
||||
ObservableWrapper.callEmit(messageBuses.worker.to(CHANNEL),
|
||||
{'method': TEST_METHOD, 'id': ID, 'args': [PASSED_ARG_1]});
|
||||
ObservableWrapper.subscribe(messageBuses.worker.from(CHANNEL), (data: any) => {
|
||||
expect(data.type).toEqual("result");
|
||||
|
|
|
@ -52,7 +52,7 @@ export function main() {
|
|||
serializer.deserialize(serializer.serialize(viewRef, RenderViewRef), RenderViewRef);
|
||||
webWorkerEventDispatcher.registerEventDispatcher(viewRef, eventDispatcher);
|
||||
|
||||
ObservableWrapper.callNext(messageBuses.ui.to(EVENT_CHANNEL), {
|
||||
ObservableWrapper.callEmit(messageBuses.ui.to(EVENT_CHANNEL), {
|
||||
'viewRef': viewRef.serialize(),
|
||||
'elementIndex': elementIndex,
|
||||
'eventName': eventName,
|
||||
|
|
|
@ -85,10 +85,10 @@ export class MdInput {
|
|||
|
||||
updateValue(event) {
|
||||
this.value = event.target.value;
|
||||
ObservableWrapper.callNext(this.mdChange, this.value);
|
||||
ObservableWrapper.callEmit(this.mdChange, this.value);
|
||||
}
|
||||
|
||||
setHasFocus(hasFocus: boolean) {
|
||||
ObservableWrapper.callNext(this.mdFocusChange, hasFocus);
|
||||
ObservableWrapper.callEmit(this.mdFocusChange, hasFocus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ export class MdRadioGroup implements OnChanges {
|
|||
this.value = value;
|
||||
this.selectedRadioId = id;
|
||||
this.activedescendant = id;
|
||||
ObservableWrapper.callNext(this.change, null);
|
||||
ObservableWrapper.callEmit(this.change, null);
|
||||
}
|
||||
|
||||
/** Registers a child radio button with this group. */
|
||||
|
@ -179,7 +179,7 @@ export class MdRadioGroup implements OnChanges {
|
|||
|
||||
this.radioDispatcher.notify(this.name_);
|
||||
radio.checked = true;
|
||||
ObservableWrapper.callNext(this.change, null);
|
||||
ObservableWrapper.callEmit(this.change, null);
|
||||
|
||||
this.value = radio.value;
|
||||
this.selectedRadioId = radio.id;
|
||||
|
|
|
@ -147,7 +147,7 @@ class OrderItemComponent {
|
|||
@Input() item: OrderItem;
|
||||
@Output() delete = new EventEmitter();
|
||||
|
||||
onDelete(): void { this.delete.next(this.item); }
|
||||
onDelete(): void { this.delete.emit(this.item); }
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
|
|
@ -54,7 +54,7 @@ class Pane {
|
|||
<table cellpadding="3">
|
||||
<tr>
|
||||
<td><ng-content></ng-content></td>
|
||||
<td><user [handle]="user" (reset)="reset.next()"></user></td>
|
||||
<td><user [handle]="user" (reset)="reset.emit()"></user></td>
|
||||
</tr>
|
||||
</table>
|
||||
</pane>
|
||||
|
|
|
@ -11,9 +11,9 @@ export class Zippy {
|
|||
toggle() {
|
||||
this.visible = !this.visible;
|
||||
if (this.visible) {
|
||||
ObservableWrapper.callNext(this.open, null);
|
||||
ObservableWrapper.callEmit(this.open, null);
|
||||
} else {
|
||||
ObservableWrapper.callNext(this.close, null);
|
||||
ObservableWrapper.callEmit(this.close, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue