untangled

NEW CHANNEL: #fulcro
sova-soars-the-sora 2016-12-20T01:59:26.000763Z

Hi, I just git-cloned the Untangled Template and want to play around with it. When I start up my lein repl and type in (go) I get a server running on 3000 but all it says is "Loading" ... I see code for a Login UI but it is not apparent how to activate it.

cjmurphy 2016-12-20T02:19:07.000766Z

@sova: You need two REPLs to be running - called 'configurations' in IDEA. One normally called 'Server' and the other 'Figwheel'. Is 'Figwheel' running as well?

cjmurphy 2016-12-20T03:11:25.000769Z

Hmm - what I said is more liely true for the tutorial (never used the template), which is probably the recommended place to start playing around.

cjmurphy 2016-12-20T03:11:38.000770Z

likely

sova-soars-the-sora 2016-12-20T06:19:08.000780Z

@cjmurphy I just found another projct on github that was very similar, https://github.com/untangled-web/untangled-template-workspace I got it working using (start-figwheel) as opposed to (go) and I'm looking forward to tinkering. Thanks for your assistance

cjmurphy 2016-12-20T06:25:58.000782Z

np. If you only have the Figwheel version going (not (go) as well), then you may have a client side only checkout.

2016-12-20T07:45:03.000785Z

is there a way to trigger a remote re-read after a remote transaction with untangled?

2016-12-20T07:45:37.000786Z

i.e. wait for the remote transaction to complete and return, before triggering the re-read client-side

mitchelkuijpers 2016-12-20T09:28:52.000794Z

@danielstockton yes that is default behavior with Untangled

2016-12-20T09:30:03.000795Z

Default behaviour how @mitchelkuijpers? I mean, how do you specify the keys/queries to re-read?

mitchelkuijpers 2016-12-20T09:31:56.000796Z

@danielstockton If you fire a mutation and a read in one transaction, then untangled will first run the mutation wait for it to return from remote and then fire the remote read.

2016-12-20T09:33:44.000797Z

"Untangled uses Om to manage the UI, and as such the UI refresh story is Om’s story." I don't believe this is the case with Om, the reads fire immediately once the mutation runs on the client.

2016-12-20T09:34:00.000798Z

Are you talking about with om/transact! ?

mitchelkuijpers 2016-12-20T09:34:37.000799Z

Yes, with regards to remote mutations and reads (that was the question right?)

2016-12-20T09:38:55.000800Z

Yep. In my tests, the reads get fired immediately and don't wait for the remote response.

2016-12-20T09:39:19.000801Z

I've been trying to fire empty read transactions in merge to make it happen but no success.

mitchelkuijpers 2016-12-20T09:40:12.000802Z

What exactly are you trying to do? Maybe you can give more context? And what are you doing with merge?

2016-12-20T09:41:02.000803Z

The use-case is to fire a login transaction which triggers a remote request and receives a token. I then want to re-read the component query to fetch data that requires authorization.

2016-12-20T09:41:50.000804Z

Since follow-on reads seemed to fire immediately, at the same time as the login transaction, I was trying to trigger another remote re-read in merge somehow

mitchelkuijpers 2016-12-20T09:42:16.000805Z

Do you want a local read or a remote read?

2016-12-20T09:42:30.000806Z

remote, but it first needs to receive the token to authenticate

2016-12-20T09:42:39.000807Z

its not good triggering it before login responds with the token

mitchelkuijpers 2016-12-20T09:43:53.000808Z

If you use a tempid and and then return the token from the remote mutation under that tempid you can do a transaction with the mutation and the read in one. And then Untangled will wait with the remote call until the mutation returns and it will replace the tempid with the actual token before sending the read to the server

mitchelkuijpers 2016-12-20T09:44:58.000809Z

It should really not be necessary to fiddle with merge

mitchelkuijpers 2016-12-20T09:46:43.000810Z

(I could still be wrong and misunderstanding something)

2016-12-20T09:47:02.000811Z

I see. I'm actually dealing with a Django API on the backend and haven't really dealt with tempids at all but I'll look into it. Thanks for the tip.

mitchelkuijpers 2016-12-20T09:47:29.000812Z

And otherwise there is also a callback when a remote mutation returns

mitchelkuijpers 2016-12-20T09:47:35.000813Z

that might even be more interesting

mitchelkuijpers 2016-12-20T09:47:51.000814Z

(defmulti post-remote-mutate (fn [state k p] k))

(defmethod post-remote-mutate :default
  [state k p]
  (log/info "Default post remote mutate: ~{k}")
  nil)

mitchelkuijpers 2016-12-20T09:48:06.000815Z

And you give untangled this option:

:mutation-merge post-remote-mutate

2016-12-20T09:49:35.000816Z

Is this not similar to doing it in merge? Untangled implements the post mutate hooks in a custom merge I presume.

2016-12-20T09:50:18.000817Z

I haven't actually made the leap to untangled yet, but I'm trying to understand how things are implemented. I haven't fully got to grips with om so I'm reluctant to add another layer of abstraction on top.

mitchelkuijpers 2016-12-20T09:51:43.000818Z

Aha ok, I started the same way.. Until I was completely fed up with fixing all the remote stuff myself

mitchelkuijpers 2016-12-20T09:52:52.000819Z

Untangled is a pretty thin layer actually on top of OM. But I get the hesitation. The thing that helped me over the leap was the awesome network plumbing: http://untangled-web.github.io/untangled/reference/reference.html#_overall_network_plumbing

mitchelkuijpers 2016-12-20T09:53:17.000820Z

I think you could say this is pretty similar to doing it in merge btw

2016-12-20T09:57:52.000821Z

Yes, it seems that untangled just adds some opinion where it's lacking, which is good. I will probably make the switch when I really feel like I understand om and am re-implementing a lot of patterns I see are already in untangled. Honestly, it's still an experiment at this stage, I get the problems that om is trying to solve and am just trying to discover the tricky edges in a real-world app.

2016-12-20T10:02:37.000822Z

Does untangled have a story for file uploads as well, do you know? Or some hooks that make it possible?

mitchelkuijpers 2016-12-20T10:03:05.000823Z

No not really I don’t think it fits the whole reads and mutation storty

mitchelkuijpers 2016-12-20T10:04:09.000824Z

We actually don’t use the untangled server part btw, so you could start only using the client

2016-12-20T10:04:52.000827Z

Yeah, I didn't think the server part was mandatory

mitchelkuijpers 2016-12-20T10:05:39.000828Z

No it definately isn’t. For us honestly it felt awesome moving because we kind of had the same things that untangled fixed but way more ad-hoc. And removing all read functions felt awesome 😛

mitchelkuijpers 2016-12-20T10:06:53.000829Z

But I think it is good to first try vanilla om.next that way you appreciate it way more

1
tony.kay 2016-12-20T18:31:23.000852Z

@sova There are two REPLs required. One to run the client-side build process during dev, and one to run the server for full-stack. (go) starts the SERVER side (not client builds) (start-figwheel) starts figwheel (client builds and hot code push)....only used in dev

tony.kay 2016-12-20T18:31:38.000853Z

I thought the README explained that...if it doesn't that needs fixed

tony.kay 2016-12-20T18:32:15.000854Z

Ah, it only shows it in IntelliJ...the command line stuff only shows the server, so the docs need improved

tony.kay 2016-12-20T18:35:27.000855Z

@danielstockton So, some clarifications: 1. Reads after writes (all remote). Basically we have a built-in mutation called untangled/load that you can mix into your transact!. You can also compose load-action into your mutations. So yes, there is support for that. The dev guide talks about this in great detail. There are also cookbook recipes.

tony.kay 2016-12-20T18:35:48.000856Z

2. Image uploads. We did that via mutations and js API to pull image data into a base64 string

tony.kay 2016-12-20T18:35:59.000857Z

See the image library/crop tool in the untangled-components library

tony.kay 2016-12-20T18:36:31.000858Z

(Note that lib is very alpha...but you can see what you're looking for). The image lib/crop tool are actually pretty close to production ready.

tony.kay 2016-12-20T18:36:46.000859Z

and allow you to plug metadata and image storage in as components

tony.kay 2016-12-20T18:38:33.000860Z

3. The merge plugin is more around dealing with return values. I'd recommend explicit remote reads over return values (because you're messing with global merge when messing with merge). But, Om only makes return values available during merge. A multimethod here makes it pretty safe...still, reads are very clear. You might also look at the untangled-template, which has a simulated login that does exactly that.

tony.kay 2016-12-20T18:39:24.000861Z

You are right that follow-on reads are about UI rendering

tony.kay 2016-12-20T18:40:12.000862Z

Om does add a quoting/remoting story to the query syntax that we ignore in Untangled, since it requires implementing parser emitters in order to make it work. Instead we give you direct load functions, mutation triggers, and composition into mutations

tony.kay 2016-12-20T18:44:25.000865Z

4. This line of server code that is faking the success of (3) on the server : https://github.com/untangled-web/untangled-template/blob/develop/src/server/untangled_template/api/mutations.clj#L12

sova-soars-the-sora 2016-12-20T19:54:48.000869Z

@tony.kay thanks a lot. after a lot of researching i think untangled brings the best synthesis of great ideas so i'd really be happy to see it grow and develop (as well for my own understanding of the code)

tony.kay 2016-12-20T20:22:05.000872Z

@sova You're welcome. On growth: yes, that would be good. I'm not the best at marketing. We're in a relatively small corner of the webdev world. Word of mouth never hurts 😉

davewo 2016-12-20T20:29:42.000873Z

untangled-template is no longer a leiningen plugin? To use it now, we just clone and go?

tony.kay 2016-12-20T20:29:50.000874Z

correct

tony.kay 2016-12-20T20:30:05.000875Z

maintaining the lein bit is hard, and not compatible with boot, etc

tony.kay 2016-12-20T20:30:12.000876Z

so there are scripts for renaming things

davewo 2016-12-20T20:30:23.000877Z

ah, nice. thanks!

tony.kay 2016-12-20T20:30:41.000878Z

bin/rename-project.sh

tony.kay 2016-12-20T20:30:57.000880Z

or make rename

tony.kay 2016-12-20T20:31:29.000881Z

Also, if we add something to the template if you're based on a clone (or fork) you might have some success merging in the changes.

👍 1
davewo 2016-12-20T21:34:30.000888Z

fixed a portability issue with bin/rename-project.sh... wasn't working with gnu-sed. Pushed to develop.

tony.kay 2016-12-20T21:34:42.000889Z

awesome, thanks

tony.kay 2016-12-20T21:34:49.000890Z

go ahead and merge to master

davewo 2016-12-20T21:35:38.000891Z

done