fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
peterdee 2020-12-24T00:27:55.305800Z

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?

peterdee 2020-12-24T18:50:54.314800Z

Thanks, @lgessler! That was real close. It works with “Controlled” as a symbol in the :require.

🚀 1
lgessler 2020-12-24T19:07:58.315300Z

np!

lgessler 2020-12-24T03:27:25.306700Z

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 #(...)}))

2020-12-24T07:57:35.308800Z

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?

Gleb Posobin 2020-12-24T08:10:49.309700Z

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.

Gleb Posobin 2020-12-24T08:11:26.310Z

https://book.fulcrologic.com/#Networking

tvaughan 2020-12-24T11:36:58.311300Z

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.

2020-12-24T14:32:16.311500Z

thanks a lot for your answers.

Jakub Holý 2020-12-24T15:01:49.311900Z

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

2020-12-24T16:23:39.312300Z

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

🎉 3
Gleb Posobin 2020-12-24T16:24:50.312700Z

@tvaughan 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.

💡 1
tvaughan 2020-12-24T17:09:19.314500Z

Thanks for the clarification @posobin

2020-12-24T19:23:50.317400Z

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.

lgessler 2020-12-24T20:18:46.318200Z

@neo2551 yes, it is possible: like @holyjak 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

2020-12-24T20:21:10.318600Z

Oki!

2020-12-24T20:21:15.318900Z

Thanks!

2020-12-24T20:21:35.319700Z

I guess in the worst case I can use re frame and fulcro together xD

2020-12-24T20:37:20.319900Z

Here's an example using a hasura graphql backend: https://github.com/codonnell/crudless-todomvc

❤️ 1
Gleb Posobin 2020-12-24T08:07:13.309500Z

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.

Alex Piers 2020-12-24T11:07:17.310900Z

The section is in the Fulcro2 book: https://book.fulcrologic.com/fulcro2/#GraphDB

Jakub Holý 2020-12-24T15:52:20.312100Z

Good catch, Gleb! Perhaps send a PR to change the link to what Alex suggested?

Gleb Posobin 2020-12-24T16:27:29.313Z

It's a link to the fulcro 2 book though.

Gleb Posobin 2020-12-24T16:27:57.313200Z

Maybe there are some differences? Why is it not in the fulcro 3 book?

Gleb Posobin 2020-12-24T16:44:56.313500Z

Also, I didn't know there is a github repo for the fulcro book!

Gleb Posobin 2020-12-24T16:58:33.314200Z

The core concepts section the fulcro2 book is very useful, surprised it is not in the fulcro3 book!

tony.kay 2020-12-24T19:54:26.318100Z

That was a serious oversight…moved to F3 and updated as best I could in short time: https://book.fulcrologic.com/#_core_concepts

👍 2
🎉 2
2020-12-24T21:33:59.323900Z

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”

2020-12-25T15:28:28.328200Z

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:

2020-12-25T15:28:48.328400Z

2020-12-25T15:37:30.328800Z

I’ll give column formatters a shot..

Gleb Posobin 2020-12-24T23:39:26.324100Z

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:"

Gleb Posobin 2020-12-24T23:39:38.324300Z

Though it was missing from the fulcro2 book too.