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

Event dispatcher #18316

Merged
merged 2 commits into from
Aug 14, 2015
Merged

Event dispatcher #18316

merged 2 commits into from
Aug 14, 2015

Conversation

DeepDiver1975
Copy link
Member

@DeepDiver1975 DeepDiver1975 added this to the 8.2-current milestone Aug 14, 2015
@PVince81
Copy link
Contributor

Looks nice.

We have a few other places in core where we'd need that.

By the way: in what way would this affect the assets pipeline ? Would there be two JS bundles one with the extra scripts and one without ?

@PVince81
Copy link
Contributor

We could actually dispatch a similar event after "app.php" of any app has run. Not sure about the performance though if we do it for each app in every request...

@DeepDiver1975
Copy link
Member Author

By the way: in what way would this affect the assets pipeline ? Would there be two JS bundles one with the extra scripts and one without ?

Not at all from my understanding - all scripts/styles will be summed up during rendering of the template. And the version hash of the assembled files will change based on the files included.

@RobinMcCorkell
Copy link
Member

Death to the hooks! I like this 😄


\OC::$server->getEventDispatcher()->dispatch('OCA\Files::loadAdditionalScripts');

\OC::$server->getEventDispatcher()->addListener('OCA\Files::loadAdditionalScripts', function() {
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing this is example code and isn't actually supposed to be run? Otherwise it seems odd the dispatch call is above

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get it. In this case the dispatch happens before the registration of the listeners. So the listener isn't called. Or am I totally wrong and missunderstood the EventDispatcher?

Copy link
Contributor

Choose a reason for hiding this comment

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

@MorrisJobke this block is supposed to be in the activity app's appinfo/app.php.
@DeepDiver1975 has added it only to show an example. That must be removed before merging.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this will completely mess up once the apps are not loaded in the correct order.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure - this will go into the activity app

@DeepDiver1975
Copy link
Member Author

We could actually dispatch a similar event after "app.php" of any app has run. Not sure about the performance though if we do it for each app in every request...

We have to do this slightly different

  1. load all apps
  2. emit the app-loaded hook for all of them

Otherwise an app being loaded later cannot react on a loaded event of a previous app

@PVince81
Copy link
Contributor

Anyway, I'm fine with the current approach for now.
Then we can adapt all files_* apps to load their scripts in that handler instead of app.php.

@RobinMcCorkell
Copy link
Member

👍

2 similar comments
@BernhardPosselt
Copy link
Contributor

👍

@PVince81
Copy link
Contributor

👍

@DeepDiver1975
Copy link
Member Author

Let me squash the last two commits later before merge ...

@PVince81
Copy link
Contributor

@DeepDiver1975 time to squash

@PVince81
Copy link
Contributor

Please fix the commit text

@scrutinizer-notifier
Copy link

A new inspection was created.

@PVince81
Copy link
Contributor

👍

@DeepDiver1975
Copy link
Member Author

@owncloud-bot 👽

@ghost
Copy link

ghost commented Aug 14, 2015

🚀 Test PASSed.🚀
chuck

@MorrisJobke
Copy link
Contributor

@owncloud-bot retest this please

@ghost
Copy link

ghost commented Aug 14, 2015

🚀 Test PASSed.🚀
chuck

DeepDiver1975 added a commit that referenced this pull request Aug 14, 2015
@DeepDiver1975 DeepDiver1975 merged commit 72f829e into master Aug 14, 2015
@DeepDiver1975 DeepDiver1975 deleted the event-dispatcher branch August 14, 2015 17:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants