15 Matching Annotations
  1. Sep 2024
    1. I emphatically disagree with BlueFish about observers being difficult to properly unit test. This is precisely the biggest point that distinguishes them from lifecycle callbacks: you can test observers in isolation, and doing so discourages you from falling into many of the state- and order-heavy design pitfalls BlueFish refers to (which again I think is more often true of lifecycle callbacks).
  2. Nov 2021
    1. In effect, the $ syntax we've seen above will actually setup a subscription to the store. And the subscription will be cancelled when the component is destroyed. If the store is subscribed by multiple components, the store will be disposed only when the last component unsubscribes (it will be reinitialized, if a new subscription is made). This is very handy to manage the lifecycle of disposable things in your code.
  3. Mar 2021
    1. Third configurable block to run.

      I like how they identify in the description which order things run in: 1st, 2nd, 3rd, and last.

      Though, it would be more readable to have a list of them, in chronological order, rather than having them listed in alphabetical order.

    2. Last configurable block to run. Called after frameworks initialize.
  4. Jan 2021
    1. Knowing exactly what happens in your application can mean the difference between feeling in full control or experiencing deep frustration. Personally, unknowns drive me crazy, which in turn often leads to all sorts of experiments and/or debug sessions.
    1. beforeUpdate(async () => { console.log('the component is about to update'); await tick(); console.log('the component just updated'); });
  5. Oct 2020
    1. The best place to initialize a FormValidation instance is inside the component's onMount event:

      Why? Presumably because it needs access to a form element (document.getElementById('loginForm'))...

  6. Sep 2020
    1. With useEffect, you can handle lifecycle events directly inside function components. Namely, three of them: componentDidMount, componentDidUpdate, and componentWillUnmount. All with one function!
  7. Aug 2020
    1. It's recommended to put the fetch in onMount rather than at the top level of the <script> because of server-side rendering (SSR). With the exception of onDestroy, lifecycle functions don't run during SSR, which means we can avoid fetching data that should be loaded lazily once the component has been mounted in the DOM.