Mobx offers observer package which is only compatible with react, it makes it known to the store that data is being used and will rerun component on change. How do you replicate mobx observer support?
Asked
Active
Viewed 389 times
2 Answers
1
Mobx observers can be used like this:
@observable
name = 'bob'
function render( n ){ return (`<div>Hello ${n}</div>`) }
autorun( () =>{
document.getEelementById('baseOfApp').innerHTML = render( name )
})
As name changes the function passed to autorun will be re-run. In this code react and mobx-react are not being used.

Brian C.
- 6,455
- 3
- 32
- 42
1
Mobx is not only for React is universal State management. That is even more technical solution for solving common problem in JavaScript apps.
You do not even need to use Provider component from react-mobx lib if you need propagate updated model into DOM.

Juraj
- 260
- 2
- 5