Comments (2)
Good question. However, the halting problem need not apply since we actually run the codeΒ β there is no static analysis or deterministic algorithm. Conceptually this is not that complicated (it is also, by the way, how signals work and how vue works βΒ it is a clever trick though), in your example:
function total () {
if (data.logTotal == ifMathTheoremIsTrue()) {
console.log(`Total: ${data.price * data.quantity}`);
}
}
we start by running the function and observing which properties are touched. Given a state of:
data = {
logTotal: 1,
price: 1,
quantity: 10
}
And given that ifMathTheoremIsTrue() has no dependencies on data
and returns 1
, then the dependencies of the first run are:
data.logTotal, data.price, data.quantity
The only time we need to re-run this function are if any of those dependencies are changed. Lets say logTotal
now changes to 1. We re-run the function and the dependencies are:
data.logTotal
we can now diff the dependency results:
| data.logTotal, data.price, data.quantity
|---------------------------------------
| data.logTotal
|---------------------------------------
call $off on data.price, data.quantity
Hope that helps clear up how this works π
from arrow-js.
Ah, that's very helpful! I also had this question. When I first read the documentation it seemed like magic, but now I see it just tracks the dependencies from each run. If logTotal
changes to false, the function will run again and now it will know that price
and quantity
are no longer relevant. If logTotal
changes back to true, it will know to start tracking price
and quantity
again. Very clever indeed!
from arrow-js.
Related Issues (20)
- SSR
- Hydration HOT 5
- Feature request: event helpers (like: @click.outside)
- Feature request: add a second parameter for the template function (options object) HOT 4
- fails to render with multiple expressions in an attribute HOT 6
- TypeScript type for nested, optional reactive objects is broken HOT 1
- FYI: textarea behavior is very funky if you try to put HTML inside it rather than using the 'value' attribute HOT 2
- [Question] Are there ways to integrate with hyperscript interfaces? HOT 4
- Script throwing "Illegal Invocation" when adding an object to a reactive array HOT 2
- Cross-Site Scripting Vectors (XSS) HOT 5
- Dark mode flashbang π«£ HOT 1
- Rewrite a reactive property which has $on event throw error
- [bug] Docs navigation indicator is bugged scrolling past "Getting Started" HOT 1
- Element property syntax not working HOT 1
- Map, Set, WeakMap, WeakSet can't be wrapped successfully HOT 4
- Nested template being called unexpectedly HOT 2
- Array of text boxes without a good key? HOT 2
- Poor performance? HOT 1
- What are the rules for `reactive`? Can I use es2015 classes in my "state" HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arrow-js.