Skip to content

Why isn't observable.array clear method an action #3416

Answered by urugator
TruePath asked this question in Q&A
Discussion options

You must be logged in to vote

For the same reason, why assigments (eg o.foo = 5) aren't wrapped in action:

// Consider you forget to apply action here,
// this wouldn't warn:
doSomething() {
  this.array.splice();
  this.array.clear();
  this.map.set("", "");
}

It's not about whether it's an assigment or method call, any of these could represent individual and complete operation. It's kinda arbitrary decision to not consider these as "self-sufficent", but it allows us to detect missing batch in majority/lots/many/(you tell me) cases. It's not ideal though, following should ideally warn as well, but it won't:

doSomething() {
  this.action1();
  this.action2();
}

Note the internal logic of these methods is always batche…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kubk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants