keechma

Keechma stack. Mention @U050986L9 or @U2J1PHYNM if you have any questions
carkh 2019-06-02T17:01:56.050100Z

@mihaelkonjevic when i navigate to one of my counter detail page (it's just another component), i see that the subscription first returns an nil value for my counter. then the datasource's processor method is called, and everything updates as expected. I seem to remember that one of the design goals of the dataloader was to avoid such corner cases. So i guess i'm again doing something wrong ?

carkh 2019-06-02T17:03:22.051300Z

what i'm expecting is : the counter detail component only is shown when the data is ready

carkh 2019-06-02T17:04:36.052400Z

three tiered counter app going on here =) we don't want any shenanigans like a loading spinner !

carkh 2019-06-02T17:09:19.052600Z

carkh 2019-06-02T17:17:29.053100Z

mihaelkonjevic 2019-06-02T19:06:39.055800Z

@carkh for each datasource you have a -meta subscription, so if you registered counter under the :counter datasource, you can subscribe to :counter-meta datasource which will hold the information about the datasource - there you can check if the datasource is :pending or :loaded. As of the datasource’s subscription being nil that is a correct result in that point of time - since the data is not loaded yet (so the datasource will be in the :pending state).

carkh 2019-06-02T19:07:21.056800Z

ok so do this manually

carkh 2019-06-02T19:07:26.057100Z

it's ok

mihaelkonjevic 2019-06-02T19:08:27.058300Z

Dataloader is loading data asynchronously even if you return the data synchronously from the loader fn - most datasources are going to be async anyway. But, it should be returned inside one reagent’s render cycle

mihaelkonjevic 2019-06-02T19:09:07.059Z

the reason for async behavior is that the dataloader is using channels under the hood - to orchestrate the promises

carkh 2019-06-02T19:09:33.059500Z

ok good thanks.... one more question

carkh 2019-06-02T19:09:51.059900Z

pipeline controllers do not have access to the app-db-atom ?

carkh 2019-06-02T19:10:04.060100Z

like regular controllers

carkh 2019-06-02T19:10:17.060300Z

just the value itself ?

carkh 2019-06-02T19:11:27.061100Z

i'm bombarding you with questions, feel free to send me away =)

mihaelkonjevic 2019-06-02T19:11:55.061700Z

don’t worry about it, I enjoy answering questions about keechma 🙂

mihaelkonjevic 2019-06-02T19:13:12.063200Z

so, normal pipeline functions don’t have access to the atom, but there is an escape hatch if you really need it. What is your use case?

carkh 2019-06-02T19:13:42.063700Z

i said earlier that i had made a app-db logging controller

carkh 2019-06-02T19:13:48.063900Z

it's a regular controller

carkh 2019-06-02T19:14:11.064500Z

i was trying to perfect this and debounce the logging because i get many logs of the app-db

mihaelkonjevic 2019-06-02T19:14:42.065100Z

ok, so there is something that you can use for that use case - tasks

mihaelkonjevic 2019-06-02T19:14:55.065600Z

it’s not documented yet but it’s pretty battle tested

carkh 2019-06-02T19:15:02.065900Z

so i want to try using a pipeline controller to make use of the exclusive and delay-pipeline things

mihaelkonjevic 2019-06-02T19:17:24.068200Z

we are using it for animations and some other advanced needs, like event handlers inside the pipeline controllers. The idea behind tasks is that they can be inserted in the pipeline and (potentially) block the pipeline until they’re done. The task processor fn will run on every signal from the producer fn, and there is a built in task that can be used to listen to the app-db changes

carkh 2019-06-02T19:17:31.068700Z

(though i could do this from a regular controller i wanted to go "modern")

carkh 2019-06-02T19:17:55.069400Z

mhh that's in the toolbox ?

mihaelkonjevic 2019-06-02T19:18:14.069800Z

We still use regular controllers when there is a need, so pipeline controllers just solve one specific use case

mihaelkonjevic 2019-06-02T19:18:20.070200Z

Yeah, tasks are in a toolbox

carkh 2019-06-02T19:18:34.070800Z

i'll have to investigate this

mihaelkonjevic 2019-06-02T19:18:37.070900Z

Let me do a real qucik implementation of the logger with tasks

carkh 2019-06-02T19:19:15.071900Z

well i'm doing this for training purposes more than actual need... don't go out of your way for that

carkh 2019-06-02T19:19:55.072700Z

i must say until now every worry or doubt about keechma has been squashed, but i'm glad i started with a silly app rather than the real thing

mihaelkonjevic 2019-06-02T19:32:45.072900Z

mihaelkonjevic 2019-06-02T19:33:20.073800Z

so the app-db-change-producer is already debouncing the changes so it should be called less frequently than if you just use add-watch

carkh 2019-06-02T19:34:15.074700Z

reading it

mihaelkonjevic 2019-06-02T19:34:47.075400Z

We are using tasks in cases where you want to have a subprocess running and potentially updating app-db multiple times before releasing and letting the pipeline to continue. They were created because we needed a way to do state based animations

mihaelkonjevic 2019-06-02T19:36:09.076200Z

for instance wait-dataloader-pipeline! function which you can use inside the pipeline to wait until the dataloader is done with loading all datasources is using tasks under the hood

carkh 2019-06-02T19:36:31.076600Z

i need to digest this and play with it

mihaelkonjevic 2019-06-02T19:37:23.077300Z

also, blocking tasks are “managed” - which means they will be stopped when the controller is stopped. If you use non-blocking-task! flavor, you must stop them manually

carkh 2019-06-02T19:38:07.077800Z

allright ! thanks again

carkh 2019-06-02T19:38:51.078200Z

hum i see the :on-start key, where are those listed ?

mihaelkonjevic 2019-06-02T19:42:06.080900Z

:on-start is the same as :start for pipeline functions, but we added another name when we allowed the synchronous start and stop functions too. So instead of (constantly true) for params, first argument can be an object that has :params, :start and :stop functions - these are the lifecycle functions that are called synchronously (just like in the regular controllers) and must return app-db. So it made sense to have :on-start and :on-stop in pipeline functions to signalize that they are async

carkh 2019-06-02T19:43:19.081400Z

allright i understand

carkh 2019-06-02T19:45:30.081800Z

thanks again for your kind help, i'll be sure to bother you again soon =)

mihaelkonjevic 2019-06-02T19:46:11.082200Z

Please do ;)