Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObservableValueSpyEvent missing for changes in an ObservableList #885

Open
HerrNiklasRaab opened this issue Dec 10, 2022 · 1 comment
Open

Comments

@HerrNiklasRaab
Copy link

HerrNiklasRaab commented Dec 10, 2022

I expected that when I spy like this:

  mainContext.spy((event) {
    if (event is ObservableValueSpyEvent) print(event);
  });

I also get notified when I add, remove issues to the list, but unfortunetly no event is fired in this case.

// The store-class
abstract class TeamBase with Store {
  TeamBase(this.name);

  @observable
  String name;

  @observable
  ObservableList<Issue> issues = ObservableList();

  @action
  void addIssue() => issues.add(Issue(issues.length.toString()));
}


// This is the class used by rest of your codebase
class Issue = IssueBase with _$Issue;

// The store-class
abstract class IssueBase with Store {
  IssueBase(this.name);

  @observable
  String name;
}

Is this a bug or not supportet? The Mobx.js does seem to have this implemented: https://mobx.js.org/analyzing-reactivity.html#spy

PS: I want to build something like this: https://www.youtube.com/watch?t=2171&v=WxK11RsLqp4&feature=youtu.be&ab_channel=Fraktio

@amondnet
Copy link
Collaborator

amondnet commented Jan 30, 2023

@HerrNiklasRaab Have you enabled spy? By default spy is disabled.
https://mobx.netlify.app/api/spy#let-us-spy

import 'package:mobx/mobx.dart';

void main() {
  mainContext.config = mainContext.config.clone(
    isSpyEnabled: true,
  );

  mainContext.spy((event) { /* ... */ });

  runApp(MyApp());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants