-
Notifications
You must be signed in to change notification settings - Fork 3
Do arrows really inc and dec? #2
Comments
Great catch. As it happens, here the app is just writing strings. m-ld does actually respect the original data type. So yeah, we're using it badly. We could change the app to write numbers instead. Note that this is not related to the conflict scenario you noticed in #3, which will still happen with numbers. Every 'increment' or 'decrement' is actually just a 'delete the old value and insert the new one'. So there are no special 'counter' semantics going on here. |
Ah, but does m-ld offer counters? Where can I read more about that? |
There's nothing built-in with basic counting semantics, no; like everyone has a bell and I just want to know the number of dings that there have been. There is a way to do this using constraints, but it hasn't been a priority so far. That's probably because something like 'likes' is not really a counter – it's a Set of people who like something, with the size of the set being displayed. In this case each of the numeric fields in this form is probably not a counter either. It might be a single-valued field with a 'max-value-wins' semantic, as we've discussed in your repo. |
I added a branch with the single-valued constraint on the quantity field, for illustration: https://github.com/m-ld/m-ld-web-starter/compare/single-valued-quantity Note the constraints API is experimental. I want to align more closely with RDF ways of doing schemas/shapes/ontologies, and in particular, have the definitions in the data rather than in the configuration. |
Great! So what is the rule now in that branch, highest quantity wins? Or latest wall-clock time? |
Max value wins, by default. Other strategies could be added! |
In Chrome, the numeric inputs have small inc/dec arrow buttons. Arrow-up and arrow-down also work.
From https://github.com/m-ld/m-ld-web-starter/blob/main/form.js#L274 and from the console log:
it seems you are writing these as strings?
I tried this by hitting Ctrl-C on the
node index.js
process, then editing in two tabs, and startingnode index.js
again. Both clones then see"Someone else is editing this value!"
.So then maybe this is not a good example of how to use m-ld properly? Maybe given that m-ld treats these values as string, change them to
"text"
inputs in form.html?The text was updated successfully, but these errors were encountered: