This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-24
Channels
- # adventofcode (18)
- # announcements (7)
- # babashka (8)
- # beginners (81)
- # calva (7)
- # cider (40)
- # circleci (12)
- # clojure (16)
- # clojure-dev (13)
- # clojure-europe (19)
- # clojure-nl (2)
- # clojure-uk (11)
- # conjure (3)
- # cursive (5)
- # depstar (21)
- # emacs (6)
- # fulcro (38)
- # graphql (1)
- # keechma (1)
- # luminus (1)
- # portal (4)
- # re-frame (2)
- # reveal (11)
- # shadow-cljs (1)
- # sql (4)
- # tools-deps (24)
- # xtdb (4)
I am a fulcro newbie, and not too up on javascript either. Following one of the excellent Fulcro videos I learned how to add a react component using react-interop/react-factory. I’d like to add the ‘Controlled’ component of react-codemirror2. In javascript, it is referenced like this
import {Controlled as CodeMirror} from 'react-codemirror2'
<CodeMirror
value={this.state.value}
options={options}
onBeforeChange={(editor, data, value) => {
this.setState({value});
}}
onChange={(editor, data, value) => {
}}/>
How can I reach the ‘controlled’ component in Fulcro?It'd look something like this (not 100% sure about the shadow-cljs syntax for the import):
(ns foo
(:require ["react-codemirror2" :rename {"Controlled" CodeMirror}])
(def code-mirror (react-interop/react-factory CodeMirror))
(defsc Foo [this props]
{...}
(code-mirror {:value (:value props)
:onChange #(...)}))
Thanks, @U49U72C4V! That was real close. It works with “Controlled” as a symbol in the :require.
I am sorry if this is a clear answer, but can you use fulcro for client side only and use different backend than Clojure with simple rest calls?
Yes, you will have to write your own remote for fulcro on the client side, and probably use pathom to parse the query fulcro is generating and send the corresponding rest query to your server.
defmutation has a rest-api method, https://book.fulcrologic.com/#_using_defmutation. I've never used it so I can't say anything more about it.
thanks a lot for your answers.
Notice you can run Pathom on the client side, as an adapter between Fulcro and REST. Or a custom rest endpoint and eg merge-component! the returned data
Here's an example doing just that with the wikipedia api: https://dvingo.github.io/pathom-client-wikipedia https://github.com/dvingo/pathom-client-wikipedia
@U0P7ZBZCK defmutation doesn't have a rest-api method by default: you need to define the :rest-api remote yourself first, it is given as an example of how the custom remotes in defmutation could look like.
Thanks for the clarification @UQ4RJ22EA
I really don’t understand anything haha. My problem is I don’t understand any of the parts of Fulcro haha. But if you tell me I can do pure client side with fulcro I might just try to start and dig into it.
@UEQGQ6XH7 yes, it is possible: like @U0522TWDA is saying, using Fulcro with a non-"standard" backend is fully supported. For a REST API for example, you'd just need to write some additional code using Pathom (which can also run in CLJS) that will help turn the output of the REST API into the form that Fulcro is expecting
Thanks!
I guess in the worst case I can use re frame and fulcro together xD
Here's an example using a hasura graphql backend: https://github.com/codonnell/crudless-todomvc
There is a link to "the graph database section" in the first paragraph of https://book.fulcrologic.com/#_eqlthe_query_and_mutation_language and it doesn't seem to lead anywhere.
The section is in the Fulcro2 book: https://book.fulcrologic.com/fulcro2/#GraphDB
Good catch, Gleb! Perhaps send a PR to change the link to what Alex suggested?
It's a link to the fulcro 2 book though.
Maybe there are some differences? Why is it not in the fulcro 3 book?
Also, I didn't know there is a github repo for the fulcro book!
The core concepts section the fulcro2 book is very useful, surprised it is not in the fulcro3 book!
That was a serious oversight…moved to F3 and updated as best I could in short time: https://book.fulcrologic.com/#_core_concepts
There is also a picture missing in the 3.4.1 part, after the words "Thus, an entire state database with 'root node' properties might look like this:"
Though it was missing from the fulcro2 book too.
In RAD, is there a report option to tell a report to use an enumerated-label vs. the enumerated-value for :enum attributed? I.e. I would like to display the enumerated-label “Super User” vs the enumerated-value “account.role/superuser”
you can add a column-formatter as a workaround, but it’s just me forgetting to handle the case probably
Happy holidays Tony! Yes, I have enumerated labels on the attr:
(def todo-status
{:todo.status/not-started "Not Started"
:todo.status/in-progress "In Progress"
:todo.status/completed "Completed"
:todo.status/archived "Archived"})
(defattr status :todo/status :enum
{ao/identities #{:todo/id}
ao/enumerated-values (set (keys todo-status))
ao/enumerated-labels todo-status
ao/schema :production
ao/required? true})
And the output shows enumerated-values:I’ll give column formatters a shot..