Fork me on GitHub
Ahmed Hassan10:07:02

How can we Normalize app-state in re-frame like Fulcro or EntityDB?


use datascript, write your schema, dump your data in. Bam ! normalized !

Ahmed Hassan11:07:22

What is size of datascript in browser?

Ahmed Hassan11:07:00

Is there any light-weight way to do it?


entitydb is stand alone


could use that

Ahmed Hassan11:07:08

Does EntityDB have similar Normalization to Fulcro.


depending on the complexity of your app, you may win by using more heavy datascript though, if you have many data manipulation queries

Ahmed Hassan11:07:09

I understand Fulcro's pattern of normalization, i've played with entitydb but don't understand it's patterns.


you know i lean more on the keechma side =)

❤️ 4

it's the same thing really


define your idents and relations, dump data in, fulcro, entitydb, datascript they all work the same way in this regard

Ahmed Hassan11:07:47

In re-frame you have to do this yourself.


you don't even have to do it at all in re-frame, might be the best choice sometimes

Ahmed Hassan11:07:50

When data model get large you need some structure.


i've done a re-frame app using datascript for keeping the business data


but it was an electron app, so i never considered space requirements

Ahmed Hassan11:07:55

I want to work with Keechma, but not able to get start even hello world running. But I like ideas.

Ahmed Hassan11:07:18

Now I'm using reitit frontend routing with re-frame.

Ahmed Hassan11:07:44

It have controllers, that react on route change.


if that works to you, that's all fine !


There is also About a year ago or so I found that datascript is about 10x slower than plain maps-of-maps manipulations. Ended up with a heavily customized version of subgraph.

👍 4
Ahmed Hassan11:07:15

@U2FRKM4TW what did you found lacking in subgraph?


@UCMNZLJ93 Hard to recall right now. After a quick look at its usage examples, I can definitely say that I: 1. Removed the need for namespaces 2. Made everything more flat and much simpler (no more "give me the name of the friend of the friend of the...") Probably something else.


I’m using Mapbox in my re-frame app, which renders to a canvas. I’m using the lifecycle methods to interact with it (component-did-mount, etc) which is ugly but seems to be the best way.


A thing I need to do, which I’m hoping for a suggestion for, is to interact with some DOM elements that the mapbox thing creates. In particular when I create a pop-up on the map, I have to use javascript interop and pass a raw HTML string to a setHTML function on the map object


Hi @credulous! Following works for me with OpenLayers. I haven't used MapBox so I don't know if any of this can be applied but I hope you can achieve something similar. - create DOM element for the popup 'outside' the map component using React/reagent - tell OpenLayers to render popups into aforementioned DOM element - manually set the position of the popup overlay each time you need to render a new popup and inform the 'outside world' to display the popup This way you can render whatever into the popups with react/reagent (and control if they're visible or not without direct DOM manipulation). This strategy was pretty tedious to setup initially but it has been working remarkably well for me.


Again, ugly. But now I want to dismiss those popups from another part of my application, based on an app-db event.


Do I need to create an effect handler, or is there some kind of way to have a reaction function that just subscribes to the change, the way a component would?


@credulous you just call render again (with a different target element) from your lifecycle methods. Portals from React may also work (don't know enough about your usecase to say):


Or, if you use the inner-outer component strategy, you can eliminate the need for lifecycle methods:


hi, I'm using re-com's scroller component, but I need to programatically scroll to some position in the content. Does anyone know of some example code I can look at?


I would try just getting a ref to the component, then call the method on the HTML element manually


thanks isak, I'll try that!


(I know it's a re-frame channel and re-com isn't exactly part of re-frame, but it's the closest channel I could find)