Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

fix promise patching, again #37

Closed
x1B opened this issue Mar 8, 2017 · 5 comments
Closed

fix promise patching, again #37

x1B opened this issue Mar 8, 2017 · 5 comments

Comments

@x1B
Copy link
Member

x1B commented Mar 8, 2017

The angular adapter needs to hook into promise in order to kick off a digest cycle when an eventBus.publish(...) or an eventBus.publishAndGatherReplies(...) completes.

The current workaround mechanism essentially breaks the native promise by replacing it with $q, so we need to fix it.

Alternatives:

  • patch window.Promise.prototype.then to have it trigger a digest cycle when the completion/rejection callback is invoked. This is a complete solution, but may have unintended side effects, e.g. performance problems.

  • decorate axEventBus for AngularJS widgets so that publish/publishAndGatherReplies returns a decorated promise, that again triggers a digest cycle. We need to check if this covers all our bases.

@x1B
Copy link
Member Author

x1B commented Mar 8, 2017

Note: it is fine if the solution does not make Promise.resolve() magically trigger digest-cycles when used from AngularJS widgets! We just have to make sure that our libraries (laxar, laxar-patterns) function seamlessly.

@x1B x1B added this to the v2.0.0 milestone Mar 8, 2017
@x1B x1B self-assigned this Mar 8, 2017
x1B added a commit that referenced this issue Mar 8, 2017
@x1B
Copy link
Member Author

x1B commented Mar 8, 2017

Using the second variant (selectively fixing eventBus.publish and eventBus.publishAndGatherReplies).

@x1B
Copy link
Member Author

x1B commented Mar 8, 2017

Fixed on master (v2.0.0).

@x1B
Copy link
Member Author

x1B commented Mar 8, 2017

@alex3683 care to have a look?

@x1B x1B closed this as completed Mar 8, 2017
@x1B x1B removed the state: review label Mar 8, 2017
@alex3683
Copy link
Member

alex3683 commented Mar 9, 2017

@x1B looks really good to me! Less hacky and more focused. 🤓

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

No branches or pull requests

2 participants