Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

fix: fluent interface for EventEmitter #475

Merged
merged 1 commit into from
Nov 3, 2016

Conversation

jtmalinowski
Copy link
Contributor

Fixes #470 by returning self from addListener, on, prependListener, removeListener in Node.js.

const zoneAwareAddListener = makeZoneAwareAddListener(EE_ADD_LISTENER, EE_REMOVE_LISTENER, false, true);
const zoneAwarePrependListener = makeZoneAwareAddListener(EE_PREPEND_LISTENER, EE_REMOVE_LISTENER, false, true);
const zoneAwareRemoveListener = makeZoneAwareRemoveListener(EE_REMOVE_LISTENER, false);
const zoneAwareAddListener = makeZoneAwareAddListener(EE_ADD_LISTENER, EE_REMOVE_LISTENER, false, true, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO adding a "magic" boolean param is not the best way to to this.

Can you add makeChainable... that wraps the underlying method and return self ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let me know what you think now!

@@ -363,3 +363,9 @@ export function patchMethod(target: any, name: string,
return delegate;
}

export function makeNamedFnChainable(fn: (self: any, args: any[]) => any) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • pls move this fn where it is used (ie events.ts).
  • use arrow fn,
  • wouldn't callAndReturnFirstParam(...) be more explicit ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer named functions, because stack trace when debugging, but I've got nothing against good policies!

@percinor
Copy link

percinor commented Oct 8, 2016

angular/universal#568
I have modified zonejs23 or 25 util.ts and event.ts same like above ,but also error on ng2 universal project . if i work express+angular2 +mysql ,its no problem , how to solve it , thanks

@tamascsaba
Copy link

tamascsaba commented Oct 12, 2016

@vicb, @JakubMal ?? I waiting for this P.R, because wallabyjs/public#814

@jtmalinowski
Copy link
Contributor Author

Sorry, I was short on time lately, I should be able get this ready this week!

On 12 Oct 2016, at 14:21, Tamás Csaba [email protected] wrote:

@vicb, jakubmal ??


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@jtmalinowski
Copy link
Contributor Author

All issues addressed! :)

@jtmalinowski
Copy link
Contributor Author

@alxhub ?

@spenoir
Copy link

spenoir commented Dec 13, 2016

I'm hoping this PR will fix my TypeError: Cannot read property 'on' of undefined when using websockets in Angular 2. Has it been released?

@JiaLiPassion
Copy link
Collaborator

@spenoir, yes this has been released.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants