Fork me on GitHub
#fulcro
<
2020-08-19
>
tony.kay00:08:07

Anybody interested in helping a little with RAD? I’m interested in someone writing a database adapter for key-value stores that could then make it easy to use a variety of dbs like redis, firebase, mongodb, etc. I’m thinking something along the lines of: • The user of the lib supplies function (fn write* [ident cljc-map] …) that can store the given map (assumed to be normalized, so that refs are ident values within the map) for the provided ident, and (fn read* [ident]) that will return the map stored under that ident (with the idents for refs). They key is the ident, in other words. In redis, it already uses Nippy, and these two functions would be trivial. • The library would treat each “normalized” fulcro-state-db-style entity as a thing to store in such a store by ident. • Form middleware for save and delete would then be pretty easy. Schema enforcement based on attributes would be easy to include. • Auto-generated resolvers based on ID would also be trivial This would let us dramatically expand the back-end storage options, since new adapters would just need to supply two functions.

👍 6
cjmurphy03:08:02

I would be interested in helping. Perhaps doing one of them, getting things moving along...

tony.kay14:08:00

you got a basic idea from that, or do you need more direction?

cjmurphy18:08:12

No I'm okay for now. Just looking for one of them that easy to setup and use w/out an internet connection.

tony.kay19:08:25

Just use an atom with a map 😄

👍 3
tony.kay19:08:37

“In memory database adapter”

tony.kay19:08:12

the idea is to store them like they are stored in Fulcro, so keys are idents, and values are normalized table entries that in turn have idents that point to other things

tony.kay19:08:30

The one thing I didn’t get right, @U0D5RN0S1, in the description above: The functions will receive the pathom env, which in turn can have (via plugins) database specific config info, including the key->attribute lookup map for attributes, etc.

tony.kay19:08:38

See the Datomic adapter for a bit of detail there.

tony.kay00:08:00

Ideally it would be CLJC, so it could even be used as a client-side db adapter (though we still need remote integrations to make that fully possible). Then using database-as-a-service (or browser-based dbs) APIs would be pretty easy to adopt.

tony.kay00:08:18

I could probably knock together a basic template pretty quickly, but I don’t have the time to refine/test it.

Adam Helins07:08:23

Is there a way to modify Transit handlers used by Inspect? Transit does not support sorted colls (they are ser/de as unsorted ones), which makes Inspect unusable as soon as you use one (at least, it prevents time travel which is a big let down)

tony.kay15:08:34

Follow the development directions for Inspect, and add it there, and then use development mode in F3 and add it there. It has to be added on both ends. If it is a general data type that everyone would use that does not add deps they would not use, then I’d even take that as a PR. I’m not sure what transit’s resolution order rules are, so you’d have to figure that out

Adam Helins15:08:35

Great, I am in a bit of a rush but I will probably have to do it one day or another, I'll keep that PR in mind

Adam Helins08:08:53

(Well of course, that would only be viable for colls sorted by default <, not user functions (eg. no sorted-map-by), but still)

cjmurphy16:08:50

In the Fulcro RAD Demo if you want to leave a new form a Cancel/OK modal dialog comes up with "You will lose unsaved changes. Are you sure?" Can anyone help me with where that messages comes from?

Tyler Nisonoff16:08:04

one can set it with

::form/confirm
::form/confirm  (fn [message]
                     #?(:cljs
                        (js/confirm message)
                        ))

Tyler Nisonoff16:08:18

and you can see it used in the RAD codebase in form.cljc#convert-options

cjmurphy16:08:32

Thanks @U016TR1B18E, I can see it now 🙂

Tyler Nisonoff16:08:26

Out of curiosity, was it not working for you by default? That was happening to me (and may still be..)

Tyler Nisonoff16:08:25

(I think all forms are supposed to use js/confirm with that generic message by default, but I think I had to set it manually in my project for some reason..)

cjmurphy16:08:54

Yes, not working for me trying out a form, but it works in the RAD demo, perhaps a validator is required...

Tyler Nisonoff16:08:06

oh interesting.. didn’t see any logic connecting the two, but interesting idea to try

cjmurphy17:08:46

Seems like js/confirm is nil for us but the RAD demo has it defined somehow. Very much a JavaScript thing. (Nothing to do with the validator).

Tyler Nisonoff17:08:38

cc @tony.kay just for visibility -- this is what I was asking about a few days back, never figured it out 😞 Don't know why js/confirm is occasionally nil..

cjmurphy01:08:24

Its an intriguing question. And also a potential time waster for many people. Would be good to have an error message that recommends setting ::form/confirm.

Tyler Nisonoff01:08:11

i think it can be nil in non-web environments (react native, for example), but if we know we’re in a normal web browser, it’d be nice a log/warn would nice

cjmurphy02:08:06

Good point. Also seems like it is something still under development, because ideally there would be a more global 'modal confirm dialog' way that is better looking and comes from the rendering plugin.

Tyler Nisonoff03:08:23

yeah, but I think a lot of these defaults aren’t really meant to be used in a production user-facing environment — they’re convenient for internal tools, and quick experimentation, but every app is going to have its own design, style, and thats not really the concern of the framework

cjmurphy05:08:32

And in this case the global confirm dialog could be 'app styled' by making a modification at the rendering plugin. i.e. every app can have its own rendering plugin.

tony.kay14:08:12

The problem at the moment is that confirm needs to be sync, and most things in js-land are not…it’s a problem in the design right now. That bit of code will move to return a boolean, a promise/future returning a boolean, or an async channel resulting in a boolean.

tony.kay14:08:22

then rendering plugin could do it

souenzzo16:08:03

@tony.kay Do RAD implements "server side pagination" (fetch pages one by one)

tony.kay17:08:16

@souenzzo not at present

👍 3
tony.kay17:08:09

What is there is that URL report parameters (control values) do get sent to the server; therefore the server can choose to respond with a subset of real data. For expanded options you would set a ::report/machine option on report and customize the UISM and add such support.

tony.kay17:08:59

So, if you look carefully “filtering” on the report is really client-side filtering of the server result (`row-visible?`).

tony.kay17:08:44

Therefore, you can get most of what you need on server-side pagination by adding controls that have nothing to do with client-side filtering, and send those to the server to get a subset result

tony.kay17:08:53

For example, on my system I have things like reports on all orders. Of course I don’t want all orders ever…I want them for a date range. So, the date range defaults to “today” and I auto-run the report. If the user changes the date range, then I pull those, etc.

tony.kay17:08:10

Limiting the span of the allowed date range makes it reasonable in most cases

tony.kay17:08:56

You could add a “Page” control that says what page number, and let the server do sort/filter/paginate, and just send that number as a query param to say which page you want. That would not require any change to the UISM

tony.kay17:08:14

The control’s “on change” action would change the number and re-run the report

tony.kay17:08:31

TL; DR: You can get what you want with a custom “page” control that sets a report param, and a resolver that interprets that param. The control just runs the report when it changes.

👍 6
souenzzo17:08:39

Yeah. Our app already use pagination as a custom param.