Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:28

    foxdonut on wip

    wip (compare)

  • Oct 25 16:57

    foxdonut on wip

    consolidate examples (compare)

  • Oct 25 15:37

    foxdonut on wip

    wip (compare)

  • Oct 25 11:47

    foxdonut on wip

    move eslint to a single place (compare)

  • Oct 24 19:40

    foxdonut on wip

    wip (compare)

  • Oct 22 00:27

    foxdonut on wip

    reorg (compare)

  • Oct 21 10:38

    foxdonut on gh-pages

    update random-gif example (compare)

  • Oct 21 10:38

    foxdonut on gh-pages

    update gitter-search example (compare)

  • Oct 21 00:18

    foxdonut on wip

    wip (compare)

  • Oct 21 00:00

    foxdonut on wip

    wip (compare)

  • Oct 20 20:59

    foxdonut on gh-pages

    Update gitter-search example (compare)

  • Oct 20 20:49

    foxdonut on gh-pages

    Update gitter-search example. T… (compare)

  • Oct 18 11:45

    foxdonut on gh-pages

    update docs (compare)

  • Oct 18 11:39

    foxdonut on wip

    Update docs - effects should be… (compare)

  • Oct 18 11:36

    foxdonut on wip

    One event to many triggers, ser… (compare)

  • Oct 11 18:02

    foxdonut on wip

    wip (compare)

  • Oct 11 12:18

    foxdonut on wip

    wip (compare)

  • Oct 10 23:40

    foxdonut on wip

    wip (compare)

  • Oct 10 23:40

    foxdonut on wip

    (compare)

  • Sep 27 11:31

    foxdonut on master

    working on type support for mei… (compare)

Glantucan
@glantucan
Well, I have a modal with close button which needs to execute a different action depending on the contents so I was putting the action in a property of the modal portion of the state. But I guess it's better to conditionally assign the right action from the component that contains the modal depending on the part of the state that determines waht goes inside. Never mind
Fred Daoud
@foxdonut
@glantucan :thumbsup:
let me know if I can be of any further help.
Glantucan
@glantucan
Hi again. It's been a while since I'm using meiosis to develop a single page app for students using an LMS system. The project is growing steadily and I'm quite happy with meiosis. But today while wiring up the system that saves student progress I ran into doubting what I am doing.
I understood reading the tutorials that the perfect place to do AJAX calls is on effects. But this has the disadvantage that you have to trigger an action that sets some flag on the state, the effect does the ajax call and has to set another flag (so it's not executed again when the state is updated) and when the ajax call is resolved it sets the pertinent state again, either by a callback or the promise you set on the effect.
Is this right? or is there another way?
My point is that I'm finding hard to remember where I set each part of the state: Perhaps is that I'm separating the code into too many files? (one file per mithril component, one per effect, services are grouped in files when related with the same piece of state though, and actions too)
Fred Daoud
@foxdonut
hi @glantucan
you could try triggering your AJAX call from the action itself. this would reduce the number of moving parts that you need to manage.
whether you trigger directly from the action, or using an effect, really depends on different use cases and conceptually how you prefer to structure your code.
Glantucan
@glantucan
Mmmm, ok, that makes sense. The only inconvenience of doing AJAX on an action is that, i think, you can not call another action directly when the request is resolved, for instance. Or is there a clean way to make other actions available to one action?
Fred Daoud
@foxdonut
@glantucan yes, you can call an action from another action by defining the function using theFunctionName: function(...) { ... } instead of theFunctionName: (...) => { ... } and then you can call that action from another action using this.theFunctionName(...)
Glantucan
@glantucan
Mmmm, I see, as long as they are all defined on the same file I can use this, of course. I thought about it at some point and then forgot it. I guess I am too much of a maniac of not using this for anything, but in this case the context is always controlled so it's ok. Thanks!
Fred Daoud
@foxdonut
@glantucan yes, I agree, I don't like using this either, but it's the easiest way to call an action from another, and as you said, the context does not change.
Constantin Angheloiu
@cmnstmntmn
@glantucan or create an effect that is aware of action1 completeness, and then trigger action2 that way you can use action1, action2 decoupled
so it is also scalable
Constantin Angheloiu
@cmnstmntmn
@foxdonut i was trying to create an example for @glantucan , and i face an update issue .. can you have a look here why the view is not updated even if the action is called
Fred Daoud
@foxdonut
@cmnstmntmn it looks like you have uncovered a bug with meiosis-setup/simple-stream! I will investigate.
As you can see here it works with mithril-stream
Fred Daoud
@foxdonut
@cmnstmntmn by the way, what does cmnstmntmn mean?
Fred Daoud
@foxdonut
(and for completeness, here is the example with flyd, also works)
Oscar
@osban
I'm guessing "constantin" with 'm' replacing the vowels :wink:
that's how much he loves mithril :stuck_out_tongue_winking_eye:
Fred Daoud
@foxdonut
@osban wow good catch :grinning:
Oscar
@osban
@foxdonut :grinning:
Constantin Angheloiu
@cmnstmntmn
@foxdonut hehe is constantin where each vowel is replaced by an m
@osban indeed
:))
Constantin Angheloiu
@cmnstmntmn
it might work as a barcode also :))
Glantucan
@glantucan
Thanks! @cmnstmntmn . Actually, that's kind of what I am doing, and as my application is getting bigger, I did separate actions in different files and folders. That's what's giving me headaches when trying to remember where is what, and probably improvable naming.
I know my problem has nothing to do with the pattern itself but with my scaffolding of files.
And I will share that when I have a little time to organize my thoughts about it in the near future because I think it's worth the discussion
Fred Daoud
@foxdonut
:thumbsup:
Constantin Angheloiu
@cmnstmntmn
@glantucan if you are not using sum types, have a look over them; to me, the state is way more clear since i am using it
here's @foxdonut static-tagged-union implementation
Glantucan
@glantucan
Thanks! Never heard of them before, mmm, think I understand the basic concept, more or less, but still too abstract for me to see how to benefit from them right away. You use them to define services and/or effects execution conditions?
Constantin Angheloiu
@cmnstmntmn
nope, just to tag data
here's a flems
you organise and tag your data you have inside your app
Constantin Angheloiu
@cmnstmntmn
and then you only have to handle the cases that data can have
i use to have Request with these cases [Loaded, Loading, Error, Saved] as a wrapper for some app specific data types
Constantin Angheloiu
@cmnstmntmn
// -- types
Request -> None Loaded, Loading, Error
User    -> Patient, Doctor, Nurse

// -- app state
state = {
    user: Request.None()
}


// -- your view then will handle them

function userTypeComponent(user) {
  return User.fold({
    Patient: (x) => PatientView(x),
    Doctor: (x) => DoctorView(x),
    Nurse: (x) => NurseView(x)
  })(user) // -- custom view based on User type
}

const view = Request.fold({
    None: () => ({message: "No user"}),
    Loaded: (x) => userTypeComponent(x),
    Loading: (x) => ({message: "Loading user type..."}),
    Error: (x) => ({message: "Error loading user"})
})(state.user) // -- custom view based on Request type

later in your app you may want to put your state into loading
and clear it's value

update({user: Request.Loading(undefined)})

then

update({user: Request.Loaded(response.data)})

...

Glantucan
@glantucan
Oh!, ok, I see. So this allows you to have a state that can have very different shapes, depending on the situation, and handle it gracefully on the view by showing the components that match that shape as it changes. Is that the gist of it?
Constantin Angheloiu
@cmnstmntmn
@glantucan here's
an example
Constantin Angheloiu
@cmnstmntmn
@foxdonut what's the easiest way to update an object value inside an array and return update({data: updatedArr}) ?
Constantin Angheloiu
@cmnstmntmn
and also keeping it's index
Fred Daoud
@foxdonut
@cmnstmntmn with mergerino?
put the index as the property, like this: update({ data: { 3: newValue } }) here is an example
Constantin Angheloiu
@cmnstmntmn
:thumbsup: ty
Fred Daoud
@foxdonut
welcome!
ryanford-dev
@ryanford-dev
are there any examples floating around using meiosis with hyperapp v2?
Fred Daoud
@foxdonut
@ryanford-dev ooof, I was following hyperapp in the early stages and trying to "nudge" them towards meiosis-like patterns, but I think it was too soon for them. Seems like they have ended up along those lines eventually, which is nice to see. I haven't looked into it lately though, so I don't have any meiosis+hyperapp examples, but someone else might.
ryanford-dev
@ryanford-dev
i can put something together assuming i get my head around it ok
v1 would be pretty straight forward, but v2 has some other concepts like effects and subscriptions idk how well they would mesh with meiosis
ryanford-dev
@ryanford-dev
rereading through the meiosis docs i'm not really sure it would work well with either tbh
Fred Daoud
@foxdonut
@ryanford-dev I would agree. Meiosis is more flexible in that it's just a pattern for data flow, and you're free to choose the view library, and adapt the pattern in different ways to suit your needs. On the other hand, hyperapp bundles everything together and you're constrained to it specifically. I'm not saying it's a bad thing, just different.