question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need help using global appModel/understanding data binding

See original GitHub issue

Hi - I am starting to learn preact/vdom/data-binding internals, and as an experiment looking to port automatic data-binding (like in vue.js framework by the use of watchers) to preact. It would be on the lines of generating a watch expression for all dependencies in a component and then subscribing to it by using Object proxies whenever an attribute changes. The idea is to implement something like this:

A global object representing the state of various pieces:

var appModel = {
  'user': {  },
  'tweets': [ ],
  'notifications': [],
  'followers': []
}

And, different components watching/binded over parts of the above model:

Preact.render(<ProfileBox user={ appModel.user } />, document.getElementById('profile'));
Preact.render(<TweetList list={ appModel.tweets } />, document.getElementById('tweetList')); 
  1. What would be a good starting point to explore this?
  2. Are there ways already with preact to achieve something like above?
  3. Are there any major challenges that are foreseen in developing an example as above.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
yaodingydcommented, Oct 3, 2017

If you are looking for a single global object model for state change, then it’s exactly what Redux is doing: one single data store which is the sole source of truth. But I think the focus of what you want to achieve is notification through mutation, not to call setState repeatedly.

0reactions
sanguptacommented, Oct 20, 2017

Am closing this one now, as my queries have been answered. Thanks to everyone on the team.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need help using global appModel/understanding data ...
Hi - I am starting to learn preact/vdom/data-binding internals, and as an experiment looking to port automatic data-binding (like in vue.js ...
Read more >
Managing model data in your app
The binding connects the view element to the underlying model so that the user makes changes directly to the model data. See Also....
Read more >
Retrieving and displaying data with model binding ...
This tutorial series demonstrates basic aspects of using model binding with an ASP.NET Web Forms project. Model binding makes data ...
Read more >
Guide to app architecture - Android Developers
Data binding library. Overview · Get started · Layouts and binding expressions · Work with observable data objects · Generated binding ...
Read more >
Chapter 4, Understanding and Using Angular Components
At its very simplest, a component is nothing but a class that encapsulates behavior (what data to load, what data to render, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found