Fork me on GitHub
#re-frame
<
2017-11-02
>
danielcompton02:11:03

@jeaye have a look at the source in re-frame.router, that's where it all lives. We don't have an API for getting a callback when the current event queue is empty, which is I think what you'd want?

danielcompton02:11:03

You could send an event through the system which would then let the backgrounding take place after the event is processed?

danielcompton02:11:59

If you wanted to live dangerously I guess you could count the number of events in the EventQueue queue field, though I couldn't really recommend it

jeaye06:11:15

I can't stop the backgrounding, if the user presses the home screen, @danielcompton.

jeaye06:11:37

I can only do as much cleanup as Android will let me before it takes away control.

jeaye06:11:59

Subscribing to a callback wouldn't help, since the work needs to be done synchronously. I need a synchronous (wait-for-event ::foo), probably, which processes every event in the queue, synchronously, until it's handled :foo. Then, as you suggested, I could queue up all backgrounding events, followed by a special event which signifies all backgrounding work has been done. I'll wait on that event to process.

jeaye06:11:00

Either way, sounds like I'll need to reach into re-frame.router to get that implemented. Thanks for the info. I'll let you know what I cook up.

abp06:11:10

Hi, I have a question regarding structure of subscriptions. We have an app with currently 3 levels of nested maps as state, each map contains for example keyword-enums that need to be translated to text-strings for the user and we have collections that need to be counted and the counts shown to the user etc. The rendering of the nested maps is currently done with one toplevel subscription and then the sub-maps are passed to the next component in the hierarchy. Now if we want to do the computations for user-strings in subscriptions we either need to add the strings to the whole map-tree before it is rendered in the subscription, or we need to write subscriptions that take Ids and compute the individual strings and use those in the components. What's a general strategy to decide on the approach and have I missed something in the documentation/examples?

abp15:11:57

Since we need to sort the individual layers vals differently we now have subs for every layer by id(s) and add subs for most of the view-logic and keyword-translations.

danielcompton07:11:24

@jeaye I'm not sure about the threading situation of react-native/android + backgrounding, but what I was imagining was: Android tells your app it is going into the background via a callback In that callback thread, your native code calls into re-frame to say "fulfil this promise when all events are processed" Block on the promise until re-frame calls you back Finish your background callback

jeaye16:11:46

@danielcompton Ah, I can see how that would work if I capture the state change on the Java level. I've been using ReactNative's AppState to provide me a callback on the state change, so I'm in CLJS land when I learn about it.

Miloslav18:11:17

Hello everyone!

Miloslav18:11:20

Right now, if you want to add a page, you need to do the following: 1. Define page component 2. Define it's route 3. Define page's name into that case that defines which page to show why not to omit third step to make the code more dry?

Miloslav18:11:41

re-frame uses case to define a page to show, but I just want to replace it with something that takes page's name and looks it up in pages namespace, and if it's found, it just returns that page, and if it's not, it returns the predefined page, for example 404 page

Miloslav18:11:58

But I don't know how to do that

eoliphant18:11:35

Um, I don’t think re-frame itself really ‘cares’ what you do in that case. Are you using secretary or something for client side routing? In any case there’s no reason that you can’t do somethign like create a function that subscribes to your current-page or whatever and translates it directly a reference to the page’s function

Miloslav18:11:41

Is it needed to explicitly require each and every page then? Or it's possible to just look up for the page with given name?

eoliphant18:11:01

in this case you shouldn’t have to (I think). You’d just return the reference to the page’s function. Not at my desk so I can’t play with it at the moment

Miloslav18:11:28

Namespaces in cljs remains unclear for me right now

eoliphant19:11:31

If you don’t figure it out, will play around with it when i get in