Clojurians
#keechma
<
2018-01-29
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

mihaelkonjevic07:01:34

@mjmeintjes Ah, makes sense. I’m not sure if the messages to the non started controller should throw an exception or just be dropped. The exception is there to help in the development. There is no reason why it wouldn’t work in a different way

mihaelkonjevic07:01:02

@mjmeintjes it also might make sense to do the event binding / unbinding in the controller layer. In cases like this I usually just send the element to the controller and then do the rest there. That way you could use the stop lifecycle function to cleanup the event handlers. It would be similar to this https://github.com/keechma/example-place-my-order/blob/master/client/src/client/controllers/order_history.cljs

mjmeintjes08:01:13

That's sort of what I'm doing as well. But how do you get a reference to the element? I've been using the ref function provided by react/reagent to send the newly created element to the controller, and then handling event binding and unbinding in there. However that's the function that's giving the error, as react seems to call it after controller has been stopped. I'll investigate it a bit further and see if it might be a bug on my end. It might make sense to not throw an exception but just log it if the controller isn't started, as currently it means the the app needs a refresh if it happens. Or provide some means of check whether controller is running from ui.

mihaelkonjevic10:01:49

@mjmeintjes interesting, I’ll have to try to reproduce it locally. What are the reagent and react versions you’re using?

mjmeintjes10:01:08

[reagent "0.8.0-alpha2"]
with shadow-cljs.

mjmeintjes10:01:35

I'll try to spend some time next weekend putting together a project that reproduces the problem.

sooheon15:01:47

@mihaelkonjevic I’m having some issues keeping forms, controllers, and dataloaders straight in my head. For example, I have a form which I want to prepopulate with data. Great, I can use an api call which returns a promise--except, I need say a customer ID as an arg to the call, and that customer ID is populated by a dataloader. Since the toolbox.forms.core get-data method receives app-db, I try (get-in app-db [:kv :customer-id]), but this is {:status :pending} and a value of nil.

sooheon15:01:52

I think I need the :deps functionality of dataloaders, but not sure how to access it in forms

mihaelkonjevic15:01:14

you can use wait-dataloader-pipeline! to wait for the dataloader to finish before you get the data from the app-db

mihaelkonjevic15:01:22

so I would load everything through the dataloader, and then just read the data from the app-db in the form

sooheon15:01:29

huh, thought for sure I’d tried that.

sooheon15:01:46

does pipeline! have to have [value app-db] as its args?

sooheon15:01:59

I think I did [_ app-db] because I wasn’t using value

mihaelkonjevic15:01:40

whatever you put there will be used as arguments for the wrapper function after the pipeline! macro does it’s thing

mihaelkonjevic15:01:37

so you should be able to use whatever - [_ app-db] should work just fine

sooheon15:01:04

Yeah it does work, guess I was impatient

sooheon15:01:27

Thanks, rereading that page helped.