Skip to content

Adde more LifecycleEvents #3863

Closed
Closed

Description

@mhevery

Currently we have:

  • OnInit / OnDestroy
  • OnCheck / OnChange
  • and OnAllChangesDone

Proposal:

  • onChanges()
  • onInit()
  • doCheck():boolean
  • Content
    • afterContentInit()
    • afterContentChecked()
    • onContentChanges() (Delayed for now)
  • View
    • afterViewInit()
    • afterViewChecked()
    • onViewChanges() (Delayed for now)

Activity

  1. mhevery commented on Aug 27, 2015

    @mhevery
    ContributorAuthor
  2. modified the milestones: alpha-36, alpha-37 on Aug 27, 2015
  3. IgorMinar commented on Aug 27, 2015

    @IgorMinar
    Contributor

    OnViewChecked and OnChildrenChecked sound good to me.

    I like the idea of letting the parent know if the stuff under changed, but I don't think that providing a number of changes is useful. It should be sufficient to know if anything changed at all, so I'd go with a boolean.

  4. added a commit that references this issue on Aug 28, 2015
    535ce44
  5. vicb commented on Aug 28, 2015

    @vicb
    Contributor

    After having seen your PR I get what the names actually mean.

    I'm not sure I like that on, do and after all 3 mean after, why different prefixes ?

    I also find content confusing (remind me of <content>)

  6. mhevery commented on Aug 28, 2015

    @mhevery
    ContributorAuthor

    @vicb

    • on (onInit, onDestroy, onChanges) Something has just happen letting you know, I don't care what you do with it.
    • doCheck - I need you to do something right now.
    • afterViewChanges - just letting you know that we have passed a certain point. Here on would sound ambiguous, and after makes it clear that it is after view changes have been processed.

    But there is still time to rename them. :-) You have other ideas?

  7. vicb commented on Aug 28, 2015

    @vicb
    Contributor

    @mhevery from your desciption above I don't get the difference of on vs after - and the doc says: OnInit (after the first check only). So really I think there should be on after everywhere:

    • OnInit -> AfterInit,
    • OnDestroy -> AfterDestroy,
    • OnChanges -> AfterChanges

    IMO doCheck is confusing for an event name. When I see lifecycle: [LifecycleEvent.DoCheck], I'm under the impression that it is a request for checking something (that would not be checked otherwise). FWIT I can't remember ever having seen an event prefixed with do (vs on, before or after). I would be satisfied with afterCheck.

    I would also use Children instead of Content.

  8. vicb commented on Aug 28, 2015

    @vicb
    Contributor

    I can see where the confusion comes from. Allow me some time to come with a better proposal.

  9. mhevery commented on Aug 31, 2015

    @mhevery
    ContributorAuthor

    So the Content/View is more descriptive over Children. Which children? View or content?.

    Any more thoughts?

  10. vicb commented on Aug 31, 2015

    @vicb
    Contributor

    Yep some more thoughts:

    The enums members are actually interface names and those interface all define a function with the same name (in lowerCase).

    May be then "Event" as in LifecycleEvent is not the most appropriate. LifecycleInterface would be more accurate but I tend to think that LifecycleMethod would be better (especially in ES5 context).

    Also as we fall back to structural type checking in TS/JS and the method names are probably too generic and might lead to collision. Some proposal:

    • onInit / onDestroy -> onDirectiveInit / onDirectiveDestroy
    • doCheck -> checkBindings
    • ...

    Misc notes:

    • Doesn't the comment for DoCheck need rework ?
    • Should we rename ViewListener methods to be more consistent (onViewCreated vs viewCreated) ?
  11. mhevery commented on Aug 31, 2015

    @mhevery
    ContributorAuthor

    @vicb

    1. yes let's rename ViewListeners method. Can you take on it?
    2. yes, the comment on doCheck needs work. Sorry I missed it. Can you also create a PR for that?
  12. assigned and unassigned on Aug 31, 2015
  13. vicb commented on Sep 2, 2015

    @vicb
    Contributor
  14. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  15. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions