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

Fix dual call issue #376

Closed
wants to merge 10 commits into from
Closed

Conversation

mjonas87
Copy link
Contributor

Description

Fix dual call issue with interactors with deferred after_performs

If an Interactor that has deferred after_performs is called from an Organizer and then...later...directly, the after_performs are skipped when calling directly.

This is due to how Organizers handle Interactors with deferred logic. In such a case, the Organizer modifies the Interactor's callback so that it is skipped. However, this does not account for cases where an Interactor is called both as part of an Organizer and on it's own. In this case, the Interactor believes it should skip handling the after_performs forever, and rely instead on the Organizer to call them at the appropriate time.

This change updates the logic so that the callback is only skipped if the organizer property is not present. This property is used to tell the Interactor that and by what it is being "organized".

Information

  • [ ] Contains Documentation
  • Contains Tests
  • [ ] Contains Breaking Changes

Fixed

  • Issue where calling Interactor with deferred after_callbacks as part of an Organizer, and then later on its own...results in the after_perform callbacks being skipped the second time.

This will only be set if the Interactor is being run in the context of an Organizer. If there are several layers of nested Organizers, then the organizer attribute will represent the immediate parent. If this is being run outside of an Organizer (just running the Interactor directly), organizer will be nil.
Previously, this only worked correctly because the caller only invoked "after_perform" callbacks. This goes a step further by only putting after_perform callbacks in this collection.
…zed logic.

Previously, if an Organizer was nested inside another Organizer, the after_perform calls were not deferred until after the outermost Organizer had finished running...which somewhat defeats the purpose (at least when nested Organizers).

This updates the logic so that if a highly nested after_perform call is deferred, it will be deferred to the very end.
Remove accommodation made for ruby 2.7 that causes it to not work wit…
If an Interactor that has deferred after_performs is called from an Organizer and then...later...directly, the after_performs are skipped when calling directly.

This is due to how Organizers handle Interactors with deferred logic. In such a case, the Organizer modifies the Interactor's callback so that it is skipped. However, this does not account for cases where an Interactor is called both as part of an Organizer and on it's own. In this case, the Interactor believes it should skip handling the after_performs forever, and rely instead on the Organizer to call them at the appropriate time.

This change updates the logic so that the callback is only skipped if the organizer property is not present. This property is used to tell the Interactor that and by what it is being "organized".
@mjonas87 mjonas87 closed this Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant