Skip to content

Emitting "remove" event on App remove? #4

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

Closed
FrankxMartino opened this issue Nov 2, 2012 · 10 comments
Closed

Emitting "remove" event on App remove? #4

FrankxMartino opened this issue Nov 2, 2012 · 10 comments
Labels
Milestone

Comments

@FrankxMartino
Copy link

When Apps get removed, add the following hooks:

BeforeAppRemove
OnAppRemove
AfterAppRemove

@ghost ghost assigned FrankxMartino Nov 2, 2012
@brianbaker
Copy link
Member

Do you think there is a need for apps to know when they are being removed (would they need to perform any tasks on removal?), or is it sufficient for containers to be the only ones that can hook into the removal process?

@FrankxMartino
Copy link
Author

I think it's sufficient for the containers to be the only ones that can hook into the removal process. That way they can remove the app from local storage for example, or from preferences on the server to keep the "workspace" state up to date.

I think the app context is only relevant when it needs to be loaded, so if an app is not loaded there shouldn't be any cleaning up it needs to do itself--at least none that I can think of right now.

@markhealey
Copy link
Member

What about apps needing to sever a user session? Or do some connection cleanup, i.e. destroy a link to a streaming service?

I'm thinking something similar to unBeforeUnload() could be quite useful for apps, particularly in the secure (iframed) app.

@FrankxMartino
Copy link
Author

At the least, I'm noticing it would be helpful to have the removeApp function act "deferred" or non-jQuery equivalent of that so we could do things like .done() once the app is removed or have a callback fire. I'm finding that when I reload an app, sometimes it registers back in before its former instance was finished fizzling out of the container.

@brianbaker
Copy link
Member

If apps have an init() method in their App Class it will be called automatically when the app is loaded. Similarly, we could allow for a destroy() method and call that so the app could do any necessary cleanup.

In thinking about this some more, I'm not sure if we really need to have before/during/after methods for this. The app render process needed it because beforeAppRender is prior to requesting an AppManifest; appRender is during the rendering of an app; and afterAppRender is when the app gets added to the DOM. In removing an app, there isn't much to do in F2. We just need to remove it from an internal collection of apps and remove the app from the dom.

We could probably just provide an appRemove hook so that if a container needed to do anything special when removing an app from the DOM, they could do so. F2 would handle its internal cleanup and also calling a destroy() on an app and then hand off control to the container to do the rest.

@Ali-Khatami
Copy link
Contributor

I have a working version of this in my app-handlers branch with unit tests to match. I would love some feedback though @FrankxMartino before submitting a formal pull request. Check it out and let me know if it looks like it will resolve this issue.

@FrankxMartino
Copy link
Author

Thanks Ali. FYI: I pulled down your version and I am taking a look.

@Ali-Khatami
Copy link
Contributor

Just an update...This has been merged into the 1.2-wip branch.

@brianbaker
Copy link
Member

Before we can release this in 1.2, we need to write some more info about it in the spec: http://docs.openf2.org/container-development.html#container-config

@markhealey
Copy link
Member

Inadvertently closed. Reopening.

@markhealey markhealey reopened this Apr 23, 2013
@brianbaker brianbaker mentioned this issue May 9, 2013
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants