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

Detect watch being executed from a middleware #1568

Open
alendit opened this issue Mar 13, 2019 · 1 comment
Open

Detect watch being executed from a middleware #1568

alendit opened this issue Mar 13, 2019 · 1 comment
Labels
enhancement 🌟 New feature ideas help wanted Help is desired questions ❔

Comments

@alendit
Copy link

alendit commented Mar 13, 2019

A middleware might wish to implement a different behavaiour based on the information if the code is being run from an editor of as a part of a watch. Currently, I don't see any obvious way to solve an issue like nikitakit/hydrogen-python#25.

Am I missing something, or do the call to middleware.execute could use so optional parameter indicating that it's called from a watch?

@nikitakit
Copy link
Contributor

I just wanted to jump in and provide some past context, although I'm no longer involved in new hydrogen development.

I had originally included this feature in the plugin API, but was instructed to remove it as part of code review (see #1179 and search for the callWatches flag). Of course, the boolean flag was just a first pass, and with greater effort it's possible to design a more general solution e.g.,

  • Converting watches into a plugin and adding a "priority" argument when installing middleware, so that plugins could choose to run before any watches trigger and only see user-initiated requests
  • Or, annotating each action with a more detailed description of its source (i.e. user-initiated, or the name of the middleware that triggered it)

Now that the plugin API is already public, there are also compatibility considerations involved when changing the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature ideas help wanted Help is desired questions ❔
Projects
None yet
Development

No branches or pull requests

3 participants