Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 19:11
    Bnaya review_requested #2233
  • 19:11
    Bnaya opened #2233
  • 19:09

    Bnaya on expose-allowStateReadsStart-end

    Expose _allowStateReadsStart/en… Update changelog (compare)

  • 16:02
    FredyC commented #2232
  • 16:01
    FredyC commented #2232
  • 15:21
    Bnaya commented #2232
  • 15:17
    Bnaya opened #2232
  • 10:08
    FredyC labeled #2231
  • 10:08
    FredyC commented #2231
  • 07:53
    kubk commented #2231
  • 04:31
    clehene opened #2231
  • 04:22
    clehene opened #2230
  • Dec 10 22:14
    elderapo commented #2228
  • Dec 10 22:02
    urugator commented #2228
  • Dec 10 20:49
    elderapo commented #2228
  • Dec 10 20:43

    FredyC on master

    Update browser support (#2229) … (compare)

  • Dec 10 20:43
    FredyC closed #2229
  • Dec 10 20:29
    jasoncrawford synchronize #2229
  • Dec 10 20:23
    jasoncrawford commented #2229
  • Dec 10 20:22
    jasoncrawford synchronize #2229
chetna
@chetnashah
got it
jay shah
@jayshah123
Is it ok to call mutating actions
In a reaction? It can cause an infinite loop right ?
Daniel K.
@FredyC
well if you call action that changes observable the reaction is listening to then yea obviously, it's endless loop :)
otherwise there shouldn't be aproblem
reaction(() => store.value, () => {
  store.value = Math.random()
})
Алексй
@gf8IDJzfohbPyYw_twitter
Hello. I am using typescript + mobx. And I want type checking to work for observable variables.
I have many observable objects. What should I use observable.box or observable.object?
In mobx types IObservableObject there is no generic, so it should be?
I would like to be able to do so
class Todo {
    state: IObservableObject<{ id: number, name: string}>
}
Daniel K.
@FredyC
@gf8IDJzfohbPyYw_twitter small tip, write observable.box somewhere and if you have vscode, you can follow type declaration for that
Алексй
@gf8IDJzfohbPyYw_twitter
Are there any workarounds to not do each time state.get().id ?
Daniel K.
@FredyC
depends, if you are within reactive context, you do it once
Алексй
@gf8IDJzfohbPyYw_twitter
The boilerplate scares me. In every place where I have to pass the object to props I have to do
<Component info={this.info.get()} />
Ugochinyere Cyrine
@1Ugochinyere_twitter
Hello, I want to set configure({ enforceActions: "never" }) in a particular store as am required to changing observed observable values outside actions .meanwhile configure({ enforceActions: "strict" }) to others stores as am not required to make the changes outside an action is this possible and how can i do it
Daniel K.
@FredyC
@gf8IDJzfohbPyYw_twitter once again it depends on your needs if you use observable.object, there is no need to call get
@1Ugochinyere_twitter I don't think it's possible to do both, why would you require such inconsistency?
Ugochinyere Cyrine
@1Ugochinyere_twitter
@FredyC . Thanks for the reply just that am using Ag Grid Component where the editing the grid tends to change the proxy objects state which throws mobx error of trying to change the state outside an action
Daniel K.
@FredyC
I am not familiar with Ag Grid, but sounds odd it would be mutating properties directly
Ugochinyere Cyrine
@1Ugochinyere_twitter
yes once you bind the the grid the proxy objects and you enable inline edit changes in the grid tend to mutate the underlying binded proxy object
Ugochinyere Cyrine
@1Ugochinyere_twitter
@FredyC plaese whats your recommendation for a large react App -- configure({ enforceActions: "strict" }) or configure({ enforceActions: "never" }) . i know the docs chose the first but i wondering the implication of choosing configure({ enforceActions: "never" })
Daniel K.
@FredyC
I personally use "never", I don't think there are implications of not having "strict"
Luca Matteis
@lmatteis
dear all. i'm looking for a way to derive data from multiple stores. how would i do this?
Daniel K.
@FredyC
@lmatteis with computeds most probably
Luca Matteis
@lmatteis
@FredyC what are those?
Luca Matteis
@lmatteis
@FredyC problem is i have like 5 different stores i need to derive data from...
Daniel K.
@FredyC
and that is a problem why? :)
Bar Ziony
@bartzy
If I'm writing my own custom hook for something, how can I make it observable?
or is it going to observable literally by using the custom hook in an observer component?
Daniel K.
@FredyC
that or utilize useObserver which essentially makes hook alone observable and does not need to depend on component to have observer as well
msrijai
@msrijai
Is mobx compatible with a parse backend?
Daniel K.
@FredyC
@msrijai please elaborate what is parse backend
Jan-Willem Spuij
@jspuij
@FredyC https://parseplatform.org/. I guess @msrijai means using Parse.Object in client side code in combination with mobx. I guess to implement change tracking etc. Parse will use some form of proxying or functions as getters / setters as well. Your safest bet would be to go to plain javascript objects first and make them observable and vice versa (with toJS() from mobx).
Bar Ziony
@bartzy
@FredyC How does that work (useObserver)? It does cause the entire function component to execute right?
Daniel K.
@FredyC
@bartzy yes it does as long as observables inside of it change
Bar Ziony
@bartzy
@FredyC so how is useObserver different than the autorun in useEffect approach here: https://mobx-react.js.org/recipes-effects (at the start of the page)?
Daniel K.
@FredyC
@bartzy that's for handling side effects, but render is not side effect :)
well in the end it kinda is when modifying the DOM, but that's not the point
Bar Ziony
@bartzy
@FredyC But I can use useObserver for anything, not only rendering.
Daniel K.
@FredyC
@bartzy I wouldn't use it for side effects, those should always within useEffect boundary
Bar Ziony
@bartzy
so only to get the "current" version of some observable value(s)?
Daniel K.
@FredyC
what useObserver does is it tracks observables within and force render component if some changes
Bar Ziony
@bartzy
and, why wouldn't you use it for side effects? it's basically using reaction and useEffect inside
Daniel K.
@FredyC
because running side effects in render phase can be unpredictable, that's not related to MobX ... why were you using lifecycle methods with class components? :)
Bar Ziony
@bartzy
@FredyC But with functional components and hooks, the "render phase" is literally just the function call itself. it's like saying that doing side effects in useEffect is doing it in the render phase
Daniel K.
@FredyC
that's not true, please read through React docs
Bar Ziony
@bartzy
@FredyC: what do you mean? can you give me an example when that's not true?
Daniel K.
@FredyC
Bar Ziony
@bartzy
@FredyC: What I mean is, useEffect is inside the render function of a function component (well, the function component IS the render function). And you do side effects in useEffect. Hooks made the "render function should be pure" argument less clear
Daniel K.
@FredyC
I don't see how is that less clear, it's just different semantics, anything that's not for rendering purposes is side effect
Gevik Babakhani
@blendsdk
I have a Mobx store (class with @observable, and @action.bound) with 3 actions each performing a REST call, and then update the @observable properties. Now I would like to have a way to set an isFetching and a fetchError for each REST call separately. Is there anyway to do this without defining 3 pares of isFetchings and fetchErrors?
kubk
@kubk

@gf8IDJzfohbPyYw_twitter I am also using TypeScript + Mobx. It is possible to define Todo state as following, no need to use IObservableObject interface:

class Todo {
  @observable state: { id: number, name: string} = { ... }
}

No need to use state.get().id, you can use state.id