Fork me on GitHub

Hi friends, over the past few months I've been thinking on and off about handling derived data in fulcro and if we could somehow combine re-frame subscriptions with fulcro to solve this problem. I have an experiment here that shows one combination of how this could work: I want to be able to use all of fulcro and not compromise on that (router, dynamic queries, mutations, state machines) and am only leveraging the subscription feature of re-frame and none of the mutation parts. The readme has more details, but the high level is that using a macro you get re-frame subscriptions generated from fulcro queries. Using these base subscriptions you can then write further subscriptions to deal with re-rendering derived data via re-frame components. This works well when your re-frame components are at the leaves of your component tree, but rendering fulcro components from the re-frame components will not always compose to root, which causes problems. I haven't played with the new fulcro hooks code but perhaps there is a way to use those here to get the benefits of fulcro with the benefits of re-frame. This is all experimental, I hope it inspires others to think about this problem and try out the code to see if there are novel ways to make writing apps even easier. The high level goal here to only ever deal with normalized data in mutations and have the subscription layer deal with determining what to re-render. I don't want to have to store denormalized data in the fulcro db or ever describe what out of band properties in the db to re-render, that should be handled for me. Some next steps to experiment with this would be to use a subscription to store an index of components by some alternative property (tasks by author or by date for example) and get the two systems to still play well together (mutating a task causes the indexed list to re-render). Hoping it inspires some more creativity in this area!

👀 5
❤️ 1

I'm a newbie but it seems this is just what I expected from fulcro in previous question on the channel yesterday I won't say if its good or bad but it for sure is an alternative concept. I'm thinking you can implement it in at least 2 way more with different query key or with different rendering optimizer is that so? it seems to me this borrows from redux javascript library am I right?


Hi. I don't believe your question is related to this. If I follow correctly, you are wondering if you always need to pass props to child components, and the answer is yes. This is a fundamental design of fulcro.


What I described is only dealing with derived data which fulcro does not maintain in its indexes, and thus cannot update efficiently without you telling it to (or doing a crude full re-render from root)


hm ok when I saw your post I thought that what you made is something that would work similarly as reducer in react-boilerplate like if something changes in the local database you would have subscription for it that would trigger a rerender which is what reducers do in react-boilerplate I was spending bit of time trying to use query as reducer from react-boilerplate without success I guess with your approach it would be possible. thats one of the things why I asked about props. its just latter that I found out from tutorials how does fulcro deal with this. thanks for reply. I'm still trying to get better grasp of fulcro so I'm not very competent to comment


Ah I see thanks for clarifying! I think it's analogous then yes. It was hard to understand without code examples.


for what I saw in javascript world there are two approaches that compete with fulcro approach when it comes to state management thats reducers approach and rxjs approach of angular where people might chose not to go with redux but use rxjs pipes. fulcro in a way competes with them with its methods and innovating a bit. it for sure is attractive to experiment with all these ideas


I'm trying to use optimized-render! keyframe/render! in latest rad and I copy pasted code from video on how rendering works but so far I can't manage to reproduce that just one person updates is rad template able to do this?


RAD requires multi-root renderer if you’re using SUI plugin, or some controls will not work.


Why do you want just a single person to update? Trying to optimize? I would recommend getting really familiar with Fulcro before trying to do anything fancy.


I'm trying now to follow fulcro tutorial how rendering works and I have trouble reproducing what Mr. Kay did there in the way I tried I hope to do what he did in the video I tried copy pasting the code into rad after cloning rad as is but I guess now it does not work due to rad using another render that behaves differently than the one in tutorial. not sure if one can specify the other renderer I just trying to force the optimized one into it like in the video 🙂 now I'm falling back to code from repository in the video trying to follow step by step until I see it working trying to get my feet wet with the fulcro it looks like a really nice software


it seems I used latest fulcro but ident optimizer is not the default anymore one has to specify it explicitly if one tries to follow tutorials with the latest fulcro if anyone searches for this in google I guess someone will spot this chat

Tyler Nisonoff21:04:24

@tony.kay r.e. the modification you recently made to m/returning What are your thoughts on a generic opts map as the additional arg rather than just query-params ? This would allow other future options such as without / other df/load! functionality I’d be happy to provide a PR if you’d like, been testing my own version


seems reasonable..but have I already messed up and used a non-map as that argument?

Tyler Nisonoff22:04:24

query-params is a map, but we’d have to nest it inside another map

Tyler Nisonoff22:04:58

i dont believe you’ve pushed a release of this code fwiw, but some may be using it


Ah, if I have not actually released it, then yes, let’s fix it


I think you’re about the only person even aware it exists

Tyler Nisonoff22:04:41

yeah i think so as well 😄

Tyler Nisonoff22:04:54

i can add a follow-up one adding without support, but it’ll require proxying data-fetch ’s elide-query-nodes and elide-ast-nodes to a helper namespace so that mutations can use those as well


Hi. I am working on a hybrid RAD and vanila Fulcro Expo/RN app. RAD on the backend and Fulcro on the frontend. I am getting the following warning consistently:

WARN [com.fulcrologic.fulcro.components:1777] - Component com.fulcrologic.fulcro-i18n.i18n/LocaleSelector does not INCLUDE initial state for com.fulcrologic.fulcro-i18n.i18n/Locale at join key :com.fulcrologic.fulcro-i18n.i18n/available-locales ; however,  com.fulcrologic.fulcro-i18n.i18n/Locale HAS initial state. This probably means your initial state graph is incomplete and props on com.fulcrologic.fulcro-i18n.i18n/Locale will be nil.
I am not using i18n anywhere in my project.