View-Model extension conflict check?
See original GitHub issueThe vm
extension idea is excellent and can mitigate a lot of “the library should have this and that” issues of contention.
But, could the DOMVM vm please provide the following function for extending so that conflicts do not silently cause strange effects, perhaps as an argument to the extension function itself?
function extend(nam,val) {
if(this[nam]!=undefined) { throw "Conflict: Cannot extend view-model with `"+nam+"` - already defined"; }
this[nam]=val;
};
Used like this:
domvm.view.extend(function(vm) {
vm.extend("state",{});
// Used directly as a property mutation preprocessor; must have no args and return undefined
var remodel=function() {
if(!vm.state.redrawPending) {
vm.state.redrawPending=true;
setTimeout(function() {
vm.state.redrawPending=false;
vm.redraw();
},0);
}
};
vm.extend("remodel",remodel);
});
or if an argument:
domvm.view.extend(function(vm,extend) {
extend("state",{});
...
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Detect conflicts manually and review conflict details
Run conflict detection manually for a change request and cancel conflict detection before it completes. Review the conflicts detected either automatically ...
Read more >Injecting ViewModel — hard to easy | by Elye - Medium
The viewModels() extension function does all that automatically behind the scene. However. If you want to inject a ViewModel that has dependencies on...
Read more >Kotlin-DataBinding-Error: Check your module classpath for ...
Issue: You have 2 XML layout files which are named the same (like content_main.xml ). Both are present in the :first-app module and...
Read more >lifecycle-viewmodel at ToT conflicts with lifecycle-viewmodel-ktx
ViewModelProviderKt exists in both lifecycle-viewmodel-ktx:2.3.1 , which gets pulled in transitively by appcompat , and lifecycle-viewmodel at head.
Read more >Stop using MVVM for SwiftUI | Apple Developer Forums
When you define the model as POJOs (simple structs) you end with many logic inside the ViewControllers / ViewModels. VC and VM should...
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 FreeTop 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
Top GitHub Comments
You mean some future where domvm has > 5 users? D:
didnt think you’d take my simple, not-that-gnarly proposal and go full-java on it, lol.
i also find it bothersome that if i were reading someone elses code, i would have no idea which calls were native and could be found in docs and which are custom extensions authored by the component’s devs.