Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

afterLoad() subscriber interface missing additional info available on other events #4185

Closed
lovrop opened this issue May 24, 2019 · 1 comment

Comments

@lovrop
Copy link
Contributor

lovrop commented May 24, 2019

Issue type:

[ ] question
[ ] bug report
[x] feature request
[ ] documentation issue

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

The subscriber interface for afterLoad() is inconsistent with the other events. All the other hooks take objects which have the entity and more context about the event (e.g. QueryRunner and EntityManager used).

The reason for this seems to be largely historical, due to how the interfaces evolved over time. The info is available in Broadcaster.ts but not passed because it doesn't fit the interface.

This was previously reported in #2510 but closed after 2 months without comment.

@lovrop
Copy link
Contributor Author

lovrop commented May 24, 2019

I think this should be easily fixable in a backward-compatible way by adjusting the interface like so:

afterLoad?(entity: Entity, event?: LoadEvent<Entity>): Promise<any>|void;

The optionality of the event parameter will keep existing subscribers working. New subscribers can use the new parameter to get additional info about the event.

I'm looking into making the change, hope to have a pull request ready soon.

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

No branches or pull requests

2 participants