GithubHelp home page GithubHelp logo

Proper Lifecycles about tko HOT 2 OPEN

knockout avatar knockout commented on July 19, 2024 5
Proper Lifecycles

from tko.

Comments (2)

ryansolid avatar ryansolid commented on July 19, 2024 2

Or how about a Hooks API instead? Those seem all the rage these days. React now uses useState to track observable state, useEffect to track computed side effects, and useMemo to track pure computed values. It's so cool that they found away to use observable primitives to avoid needing those pesky lifecycle functions at all. I even checked out the prior art section of their Documentation and they most pulled this idea from previous work of React focused libraries like Recompose and observable streams like RxJS. It's a good thing since before React I probably would never pictured a world without lifecycle methods that could work off ideas as simple as useState, useEffect, and useMemo. More that you can make stateful components with just a simple function. Just a function. The future is here.

Maybe there is a way Knockout can enter modern 2019 JS dev too with ko.observable, ko.computed, and ko.pureComputed.


Sarcasm aside. Don't go too far down this rabbit hole. Patterns are like hats. They go in and out of fashion. Keep it true to the fundamentals. It was only a matter of time before React acknowledged Knockout had the right pattern all along. Just don't expect them to admit it.

from tko.

brianmhunt avatar brianmhunt commented on July 19, 2024

So looking at the Vue.js lifecycle, I think I've gotten a decent idea of where Lifecycles could be applied in KO.

Overall, there's no over-arching / explicit lifecycle for applyBindings.

However, we can apply life cycles to binding handlers and components.

Here's a first crack at it.

Binding handlers hooks

  • BeforeCreate
  • Created
  • Bound
  • Update
  • Updated
  • Disposing
  • Disposed

Components

  • All the binding handler hooks
  • Loading Definition
  • Applying Definition
  • Definition Applied

from tko.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.