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.

View-Model extension conflict check?

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
leeoniyacommented, Apr 29, 2016

But I dream of a future with ready-made DOMVM components that are plug-n-play

You mean some future where domvm has > 5 users? D:

1reaction
leeoniyacommented, Apr 29, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

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