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

Page lifecycle events #833

Closed
wants to merge 30 commits into from
Closed

Page lifecycle events #833

wants to merge 30 commits into from

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Aug 6, 2015

Page Lifecycle Events

This PR allows ons-pages to throw lifecycle events even if they are appended to nested components (tabbar -> navigator -> page).

  • Every nested component will be wrapped inside an ons-page automatically in order to have the same API and make it homogeneous. The only exception is when the component is the main element (<body><ons-navigator> ... </ons_navigator></body>).
  • Components must implement _hide(), _show() and _destroy().
  • Every ons-page will throw show and hide when showing or hiding. This also happens after its creation, if immediately shown, and before its deletion, if it was displayed at that moment.
  • Page lifecycle events will be propagated to the page's descendants so they are correspondingly shown, hidden or destroyed. For example, destroying an ons-sliding-menu that contains an ons-navigator as the main page will throw hide event only for the displayed page but destroy event for every page in navigator's page stack.
  • The wrappers mentioned in the first point will not throw events. There is a special _muted attribute for this.
  • ons-sliding-menu and ons-split-view cannot implement this API since they are not WebComponents yet. This has been amended in L102. The only minor drawback is that menu-pages will also throw events.
  • ons-fab would also use this API to hide and show the button.

@frandiox
Copy link
Contributor Author

frandiox commented Aug 6, 2015

@anatoo @argelius before addressing the AngularJS bindings, what do you think about this?

@anatoo
Copy link
Contributor

anatoo commented Aug 6, 2015

It looks good to me. Great work!

@frandiox
Copy link
Contributor Author

@anatoo @argelius I added angular directives for the events. I'm not sure if this is the way you wanted it.
A page lifecycle event can be seen from the own page or from any parent component:

<ons-navigator ... ons-hide="doSomethingElse($event)">
  <ons-page ... ons-hide="doSomething($event)">
     ...
  </ons-page>
</ons-navigator>

Also like this $scope.myNavigator.on('hide', listener);.

There was a "destroy" directive registered in some components, but I think we were not firing any "destroy" event before. I used that one for page's destroy.

We need Japanese translation in framework/directives/page.js for the events.

@anatoo
Copy link
Contributor

anatoo commented Sep 11, 2015

This changes will merge in #896.

@anatoo anatoo closed this Sep 11, 2015
@IliaSky IliaSky deleted the page-lifecycle-events branch March 30, 2016 03:19
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

3 participants