GithubHelp home page GithubHelp logo

Comments (16)

Timbabs avatar Timbabs commented on May 19, 2024 2

Ok thanks. I didn't know I could name my observers. That helped me in resolving the issue

from mobx.dart.

Timbabs avatar Timbabs commented on May 19, 2024 2

Few observations.

@observable
 bool get loading => loadingButtonStatus 

should not be an observable.

change it to this:

@computed
 bool get loading => loadingButtonStatus 

Having said that if you had used

store.loadingButtonStatus

Then it should have also worked. And loading becomes redundant. But if you must use loading , then set it to @computed, run

flutter packages pub run build_runner watch --delete-conflicting-outputs

And try again

from mobx.dart.

stefensuhat avatar stefensuhat commented on May 19, 2024 2

@Timbabs thanks a lot mate!.

the one thing that i forget is to run that build_runner. it still using the old function i created!

and of course that loading should be @computed. 💃

from mobx.dart.

pavanpodila avatar pavanpodila commented on May 19, 2024 1

I would start by giving names to few Observers that you think are the culprits. This would have to be done by trial and error for now 😢. You could give a name like so:

Observer(name: 'test', builder: (_) {});

If you see the message with that name, you know you got your culprit.

from mobx.dart.

Timbabs avatar Timbabs commented on May 19, 2024 1

@yaymalaga
So if I get your question correctly, you're asking which of this?
1)

(in your store class)
@observable
bool loading

(in your widget class)
Observer(
  name: 'loading_button',
  builder: (_) => LoadingButton(
        loading: store.loading,
))

or
2)

(in your store class)
@observable
bool _loading

@computed
bool get loading => _loading

(in your widget class)
Observer(
  name: 'loading_button',
  builder: (_) => LoadingButton(
        loading: store.loading,
))

Both work fine. So it's your choice.

I will go for the later if concerned about class encapsulation.

from mobx.dart.

pavanpodila avatar pavanpodila commented on May 19, 2024

Fixed with #111

from mobx.dart.

Timbabs avatar Timbabs commented on May 19, 2024

I get this message:
There are no observables detected in the builder function for Observer@18
How can I trace Observer@18?

from mobx.dart.

pavanpodila avatar pavanpodila commented on May 19, 2024

Can you share the build() method where the Observer is being used? Also are you running the build_runner ?

from mobx.dart.

Timbabs avatar Timbabs commented on May 19, 2024

That's the problem. How do I know which of my observers is observer@18?

from mobx.dart.

pavanpodila avatar pavanpodila commented on May 19, 2024

Ok thanks. I didn't know I could name my observers. That helped me in resolving the issue

Great to know that. Perhaps you can make a blog post or send me a note on how you solved it and I can add it to the Guides section on mobx.pub :-)

from mobx.dart.

Timbabs avatar Timbabs commented on May 19, 2024

Great to know that. Perhaps you can make a blog post or send me a note on how you solved it and I can add it to the Guides section on mobx.pub :-)

Will do that

from mobx.dart.

stefensuhat avatar stefensuhat commented on May 19, 2024

Hi,

I'm experiencing same issue with this error "There are no observables detected in the builder function"

abstract class _AccountStore with Store {
  @observable
  bool loadingButtonStatus = false;


  @observable
  bool get loading => loadingButtonStatus;


  @action
  Future updateAccount(formData) async {
    loadingButtonStatus = true;

    Future.delayed(Duration(milliseconds: 2000)).then((future) {
      loadingButtonStatus = false;
    }).catchError((e) {
      loadingButtonStatus = false;
      print(e);
    });
  }
}

here is my widget

AccountStore store = AccountStore();

Observer(
  name: 'loading_button',
  builder: (_) => LoadingButton(
        loading: store.loading,
        text: Text('Save'),
        onPressed: () {
          store.updateAccount({});
        },
))

But everytime i run the code it always return me: There are no observables detected in the builder function

I've tried changed use store.loadingButtonStatus still the same.

any solution?

from mobx.dart.

yaymalaga avatar yaymalaga commented on May 19, 2024

@Timbabs Just out of curiosity, I would like to know which between the @computed or the @observable is recommended for a simple getter.

I mean, if I have a private observable variable like loading, is it better to just make it public and use the Observable widget, or let it remain public and use anyways the computed getter?

from mobx.dart.

eltonomicon avatar eltonomicon commented on May 19, 2024

Class encapsulation is the motivation for #220. It feels awkward to have to do a private observable and a public computed for every property of a store you want to encapsulate. I'm not sure if that syntax is best but ideally the code generator could provide a better solution.

from mobx.dart.

edukmattos avatar edukmattos commented on May 19, 2024

Hi !
Im getting this error message:

Reloaded application in 1.070ms.
Performing hot restart... 1.071ms
-- AppModule INITIALIZED
-- ClientModule INITIALIZED
No observables detected in the build method of UserName
package:flutter_web_mobile/app/modules/client/client_page.dart 169:1 build

File client_page_dart:
body: Form(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Observer(
name: 'UserName',
builder: (_) => TextField(
decoration: InputDecoration(
labelText: 'Username',
hintText: 'Pick a username',
errorText: 'Erro'
),
),
),

from mobx.dart.

pavanpodila avatar pavanpodila commented on May 19, 2024

In your builder function, there is no observable that is being used. All appear to be plain strings.

Also when pasting code enclose them in triple backticks. It makes it easier for others to read your code.
```
your code
```

from mobx.dart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.