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.

circular dependency on observed properties

See original GitHub issue

i have two properties in my model that depend on each other. I run into a loop if i want to update one of them. What can I do to avoid this? I have seen your _locked property in the two-way binding, but there are no directives in my case. I tried to set the active property on the observer to false with no effect.

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
M165437commented, Jan 7, 2016

That works. Thanks a lot! (Example on JS Bin)

var vm = new Vue({

  el: '#temperature-converter',

  data: {
    celsius: 0
  },

  computed: {
    fahrenheit: {
      get: function() {
        return 9/5 * parseInt(this.celsius) + 32;
      },
      set: function(val) {
        this.celsius = 5/9 * (parseInt(val) - 32);
      }
    },
    kelvin: {
      get: function() {
        return parseInt(this.celsius) + 273.15;
      },
      set: function(val) {
        this.celsius = parseInt(val) - 273.15;
      }
    }
  }

});
3reactions
yyx990803commented, Jan 7, 2016

@M165437 Make one of them the source of truth and make the other two computed properties. For the two computed properties, their setters should just update the source of truth.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Circular dependency - Wikipedia
In software engineering, a circular dependency is a relation between two or more modules which either directly or indirectly depend on each other...
Read more >
Circular Dependencies in Spring - Baeldung
A quick writeup on dealing with circular dependencies in Spring: how they occur and several ways to work around them.
Read more >
NG0200: Circular dependency in DI detected while ... - Angular
A cyclic dependency exists when a dependency of a service directly or indirectly depends on the service itself. For example, if UserService depends...
Read more >
java - Avoiding circular dependencies in Spring beans with list ...
Let's say that I have a Maven project using the Spring framework. The Maven project itself has three modules: common , component_a ,...
Read more >
Circular dependencies in JavaScript - YouTube
In " Circular dependencies in JavaScript" I show you what they are and how to go about solving them.You can find subscriber questions ......
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