Fork me on GitHub

@mikethompson: Has anyone ever looked at components as subscriptions? They essentially transform data in app-db into hiccup. Subscriptions transform data in app-db into arbitrary data structures. The challenges around dynamic subscriptions, or having input signals for a subscription another subscription instead of the whole app-db, or possibly a parameterized subscription, aren't they the same? Another key difference between them is how components use other components vs. how subscriptions use other subscriptions. Subscriptions never use components as input, but components can use subscriptions or other components as input. The mechanism in components where a component's render function is called again if its input parameters have changed, is the same mechanism that re-runs a subscription when its input signals change, no?


Of course a key difference is that components map to react components.


@mbertheau: yes, you are absolutely right to make the link. Same process


In 0.8 given the shift from middleware (which offers the benefit of closures) to interceptors, is there a way to forward something from :before to :after that might previously have been captured in a closure?


(fn debug-handler
    [db v]
    (let [truncated (truncate-event v)]
      (console :log {"Handling re-frame event: " truncated})
      (let [new-db (handler db v)
            diff ( db new-db)]
        (console :group {" for: " truncated})
        (console :log {"only before: " (first diff)})
        (console :log {"only after : " (second diff)})
        (console :groupEnd)
consider the above debugger (that also truncates huge messages). within closures I only have to call a (potentially very expensive truncate) once, but can use it twice. as an interceptor is it “the right way” to just tack some data like this into context :coeffects :my-truncated-thing?


@mikethompson: Yes, in my case this is correct. I will only ever have one active wolo at any given time. I thought this is how it was working, but I wanted to make sure there was nothing magic going on; I do not like magic.


@mikethompson: But what about not closing over the subscribed value in the initial setup form and instead subscribing in the return lamda? This will update values on the screen in the same way that dynamic subscriptions intend to. Is this another way to accomplish the same goal as a dyn sub? Is there a detrimental performance issue with doing it this way?


Has anyone played around with successfully?


I cant get it to forward any events yet.. not quite sure why.


On closer inspection, there seems to be an issue with using both async-flow and forward-events fx. Possibly related is unregistering on async-flow if providing a db-path will error: Assert failed: :forward-events asked to unregister an unknown id: :async/flow probably something to do with this


Ill keep tracking it down and post an issue if I find anything meaningful


@lwhorton: yes, put any data which needs to be shared between :before and :after in context under your own namespaced keyword.


But don't put it into :coeffects (within context). That map is strictly for handler inputs. Just plonk it into context itself.


This plonk-something-into-context capability is part of the reason why :context is threaded through.


@joshuanjordan given active-wolo doesn't change, then what you have will be fine. Perhaps you need a subscription called :active-wolo-details ?


@lwhorton: I've played around with re-frame-forward-events-fx successfully. 🙂


Hmm. I've been sitting here thinking about this. I can't see any way that re-frame-forward-events-fx and re-frame-async-flow could interact badly. BUT ... I have a feeling that there's one circumstance which might cause re-frame-async-flow to try and deregister itself twice (maybe resulting in the sort of error you report). I haven't yet checked the code ... but I have a question for you ... Do you have a rule set in which the one event might triggers two rules, and both these rules have a :halt true ?? (I'm wondering if that causes two halts, the second of which would display the error you are showing)