funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
martinklepsch 2017-01-04T05:24:53.000369Z

Yeah I understand what WatchEvent is used for and I think it’s great (I use it for some more complex operations) but it complicates some things I tried to implement as well

martinklepsch 2017-01-04T07:08:43.000371Z

I think I’ll need to drop Potok again despite the initial fun: 1. I’d like to use component and that quickly causes circular dependencies with the store-view 2. I’d like to make-available additional stuff when processing events without introducing globals

martinklepsch 2017-01-04T07:13:28.000376Z

(The cyclic dependency appears only because I tried to “inject” the db into the store so I can pass it to event handlers and similar)

niwinz 2017-01-04T08:12:08.000377Z

I'm not clearly understand that

niwinz 2017-01-04T08:13:08.000378Z

at least it does not make sense (the cyclic dependency...), seems like more ortanization problem that potok's problem

martinklepsch 2017-01-04T08:16:59.000380Z

I needed access to (fb/->FirebaseStub) (`:db`) in some event handlers (see point 2) and thought I could parameterize the store (a forked version of it) in a way that would allow me passing additional things to event handlers

niwinz 2017-01-04T08:17:33.000381Z

why not just define a var and access to it?

niwinz 2017-01-04T08:18:25.000382Z

an other option, just put the firebase db as a key in the state

niwinz 2017-01-04T08:18:41.000383Z

that is fully accesible on all events

niwinz 2017-01-04T08:18:58.000384Z

and in fact is its purpose

niwinz 2017-01-04T08:20:31.000385Z

later, if you want materialize that state to an "atom" but without db reference, just filter keys that you don't want see on the materialized atom, it is pretty easy to do with rx

niwinz 2017-01-04T08:21:52.000386Z

(->> store (rx/map #(dissoc % :db)) (rx/to-atom))` (or something similar)

martinklepsch 2017-01-04T08:22:13.000388Z

yeah, that seems easy enough

martinklepsch 2017-01-04T08:22:21.000389Z

I guess I jumped at component to quickly 🙂

niwinz 2017-01-04T08:22:52.000390Z

Personally, I don't see any advantage of using component on front

martinklepsch 2017-01-04T08:23:41.000391Z

yeah maybe. I like the organization and separation it enforces though

martinklepsch 2017-01-04T08:24:05.000392Z

forces you to make the dependencies explicit

niwinz 2017-01-04T08:24:35.000393Z

yeah, but that is the price of that?

niwinz 2017-01-04T08:24:54.000394Z

I mean, every decision has it's own tradeoffs

niwinz 2017-01-04T08:25:09.000395Z

some decisions has X advantadges and Y disadvantages

martinklepsch 2017-01-04T08:25:22.000396Z

@niwinz one thing with the state in watch events btw: The WatchEvent flow is async and the state is static it could become outdated and result in weird results, right?

niwinz 2017-01-04T08:25:25.000397Z

really component X is more than Y?

niwinz 2017-01-04T08:26:31.000399Z

@martinklepsch yes and no, if you perform an async op and then you want to acess to state, just emit an other event that does something as a "continuation of flow"

martinklepsch 2017-01-04T08:27:21.000400Z

I don’t know I don’t see a huge price for using component except that it doesn’t work well with some things (which can make it unbearable to use some times)

niwinz 2017-01-04T08:28:50.000402Z

for me this is already high price, designing everything to component and in future found myself, spendig time fighting with, when some new feature that I want to introduce conflicts a little bit with component

niwinz 2017-01-04T08:30:34.000403Z

I think mount is a good middle solution, on the other hand I'm not using it right now on frontend

martinklepsch 2017-01-04T08:34:11.000404Z

Hm, not a fan of mount 🙂

martinklepsch 2017-01-04T08:35:45.000405Z

I think “designing everything around component” might have some cost but also makes the boundaries of these components more clear. Which in my experience also makes them often easier to use.

martinklepsch 2017-01-04T08:36:18.000406Z

Can you remember what conflicts you had with component?

niwinz 2017-01-04T08:41:54.000407Z

No conflicts, just the effort of adapt everything to component, and maybe little conflicts like that one that you have had. It is not a hard opinion, is just a pragmatic decsions.

martinklepsch 2017-01-04T08:43:37.000410Z

yeah makes sense 👍

martinklepsch 2017-01-04T08:43:52.000411Z

I think I’ll try what you suggested, thanks for the pointer 🙂

mccraigmccraig 2017-01-04T10:14:42.000412Z

i didn't like component, but i do like being able to compactly specify systems of objects - i built something with cats to do it - https://github.com/employeerepublic/deferst

mccraigmccraig 2017-01-04T10:15:40.000414Z

(though i haven't made it work on cljs yet)

martinklepsch 2017-01-04T10:18:53.000415Z

@mccraigmccraig I’ve been meaning to understand what cats is good for for quite some time 😄 would you mind outlining how it helped with that library?

martinklepsch 2017-01-04T10:20:58.000416Z

The code isn’t immediately understandable to me, which is a good reason for me to shy away from using something ...

mccraigmccraig 2017-01-04T10:21:13.000417Z

cats does all the plumbing - i just plugged together a couple of standard monads and coerce everything to type and cats does the rest

mccraigmccraig 2017-01-04T10:21:45.000418Z

i did have to re-invigorate a couple of concepts which got retired from cats though 😬

mccraigmccraig 2017-01-04T10:28:12.000419Z

each object gets built and added to the state with https://github.com/employeerepublic/deferst/blob/master/src/deferst/system.cljc#L110 while https://github.com/employeerepublic/deferst/blob/master/src/deferst/system.cljc#L139 composes all the build operations ... everything else is peripheral

martinklepsch 2017-01-04T17:36:48.000422Z

@niwinz I ended up writing a Rum mixin that starts/stops systems and provides it to components via context, pretty happy with that solution I think. Now I want to make a defc variant that passes (partial emit! store) as first argument

martinklepsch 2017-01-04T17:37:04.000423Z

😄

martinklepsch 2017-01-04T17:42:44.000424Z

Maybe I’ll try adapting your component function for now