createViewModel doesn't respect { deep: false }
See original GitHub issueIt happens with mobx-utils 5.1.0:
const { observable } = require('mobx')
const { createViewModel } = require('mobx-utils')
const model = observable.object({ unit: null }, {}, { deep: false })
model.unit = { foo: [1,2,3] }
Array.isArray(model.unit.foo)
// => true
model.unit
// => { foo: [ 1, 2, 3 ] }
Array.isArray(view.unit.foo)
// => true
view.unit = { foo: [1,2,3] }
const view = createViewModel(model)
Array.isArray(view.unit.foo)
// => false
view.unit
// => { foo: [Getter/Setter] }
view.unit.foo
// => ObservableArray [Array] {}
It happens that I pass model to library that tries to do isArray check on some internal array of unit which mobx converted to ObservableArray. I think createViewModel could preserve shallowness to prevent such errors.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
MVVM in WPF - How to alert ViewModel of changes in Model ...
I am programming BlackJack. I have a View that doesn't have any code behind and just relies on binding to properties and commands...
Read more >Design Patterns - Problems and Solutions with Model-View ...
The Model-View-ViewModel (MVVM) design pattern describes a popular ... If the model doesn't have such a property, then the method fails by returning...
Read more >View Model Doesn't Have To Depend on ViewModel | - Medium
Basically, when the screen (fragment/activity) with this VM is closed for good. Drawbacks: ViewModel should pass through ViewModelProvider.
Read more >MVVM vs Jetpack ViewModel - what am i doing wrong - Reddit
In that definition, Jetpack ViewModel is actually consolidating the Model side of things for any kind of MV* architecture design. Yes. somehow, ...
Read more >Setting up a basic MVVM architecture in .NET MAUI
So the idea is to set up my own little 'MVVM framework' with the following ... But in our 'framework', the ViewModel doesn't...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hacky inefficient solution:
Closing for inactivity