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.

deepObserve with arrow function to also track reference changes

See original GitHub issue

While deepObserve is really nice it would be awesome if it could have an override like

deepObserve(() => objArrayOrMap, (type, change) => {})

That way if it is not only the object that can change but also its reference it could automatically pick up the change rather than having to kill and recreate the deepObserve The type sent in this change could be something like “rootChanged” or some such

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
xaviergonzcommented, Oct 23, 2018

I guess basically what I want is some kind of “deepReaction” for arrays, maps and objects without having to resort to tricks like

reaction(() => array.slice(), ...
reaction(() => entries(someMap), ...
reaction(() => entries(someObject), ...

etc.

1reaction
mweststratecommented, Oct 23, 2018

@xaviergonz why not just box the thing that might be changing?

E.g.

let target = { something : true }
const boxed  = observable({ target })
deepObserve(boxed, () => {})
boxed.target = someNewTarget
Read more comments on GitHub >

github_iconTop Results From Across the Web

Arrow function expressions - JavaScript - MDN Web Docs
An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate ...
Read more >
How To Use Javascript Arrow Functions & This Keyword
ES6 introduced a new way of writing JavaScript functions called arrow function that uses a fat arrow ( => ). This guide will...
Read more >
Understanding "this" in javascript with arrow functions
Arrow functions do not bind their own this , instead, ... Also, arrows functions are not constructors so you can not use new...
Read more >
Anomalies in JavaScript arrow functions - LogRocket Blog
This article aims to expose the major ways in which arrow functions behave differently from regular functions and how that knowledge can be...
Read more >
Quick Reference of Arrow Function in JavaScript
Arrow functions are anonymous and change the way this binds in functions. By using arrow functions, we can avoid typing function and return ......
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