Fork me on GitHub
#untangled
<
2017-02-19
>
macrobartfast00:02:16

figwheel is not seeming to work when running the todomvc client-only, and I'm getting an error code in chrome...

adambrosio00:02:59

@macrobartfast cannot reproduce, i ran on 1d35cdb origin/client-only

$> lein do clean, repl
(start-figwheel)
and went to localhost:2345/dev.html

adambrosio00:02:48

any other steps maybe?

adambrosio00:02:37

oh, @macrobartfast, it looks like you were going to index.html as your code is minimized

adambrosio00:02:15

if that’s correct, you had a bad cached version

adambrosio00:02:27

if you reload with cache off you should get a 404

macrobartfast01:02:06

badaboom... 'do clean' did the trick! thanks @adambros !

macrobartfast01:02:58

just ran the server version... everything has worked out of the box for both the client-only and server versions... this is awesome!

macrobartfast01:02:57

pretty wonderful to be able to have all this working for me so quickly. 😀

eric.shao02:02:52

@baris Thank you for you reply.But did follow the Screenshots(two repl),and the http://localhost:3000/index-dev.html shows content (the login form). But the figwheel prompt did not connected, and the chrome console repeatedly show: WebSocket connection to '<ws://localhost:3449/figwheel-ws/dev>' failed: Establishing a tunnel via proxy server failed.

tony.kay02:02:26

So, that message means that figwheel isn’t running where the js expects to find it

tony.kay02:02:55

When you start the server on port 3000 with (go), that starts the server-side web server for the application.

eric.shao02:02:56

The js has generated.

tony.kay02:02:09

Figwheel is a tool that compiles the JS AND runs a websocket

tony.kay02:02:17

it is started from the other REPL

tony.kay02:02:27

(and shows a message that tells you figwheel is compiling)

tony.kay02:02:54

If you’re seeing that error you either have an old cached version of the JS or figwheel isn’t running

eric.shao02:02:55

yes all three js has compiled, dev cards test.

tony.kay02:02:27

open dev tools in chrome and "disable js caching while devtools is open" in the settings

tony.kay02:02:32

reload browser

tony.kay02:02:30

do you have some weird network configs? proxy server? "Establishing a tunnel via proxy server failed."

tony.kay02:02:45

that might just be a secondary error of figwheel…don’t know

tony.kay02:02:11

maybe need to bypass proxy server?

tony.kay02:02:25

well, that would have made the other page fail too I think

tony.kay02:02:21

try loading from localhost:3449 and see if you get any response…the full stack ops won't work there, but it will tell you if figwheel is up

eric.shao02:02:37

ok,let me try through from beginning again.

tony.kay02:02:41

basically that is all there is to it: figwheel runs, generates (and instruments) js code with hot code reload capabilities (to be provided by figwheel on port 3449). You, however, run the server at :3000 for full-stack ops. Your code talks to port 3000, and the instrumented figwheel stuff hits 3449

tony.kay02:02:53

the figwheel port can be configured in the figwheel section of the project file

tony.kay02:02:58

I double-checked…it is not.

tony.kay02:02:06

oh, make sure you’re using the develop branch

tony.kay02:02:13

I think…let me check that

macrobartfast02:02:28

is disabling js caching different than the usual devtools settings/preferences/disable cache... ?

tony.kay02:02:31

actually master and develop are identical

tony.kay02:02:48

@macrobartfast that is exactly what I mean, yes

tony.kay02:02:57

it just ensures you don’t get old cached code

tony.kay02:02:15

You are aware of the YouTube getting started and in-the-large series, right?

tony.kay02:02:22

all on the Untangled playlist

macrobartfast02:02:28

I am, very helpful videos!

macrobartfast02:02:19

I am about to truck ahead into video 3.

macrobartfast03:02:13

is using the code snippet feature in here (using the + to the left of the slack input box) the right place to drop in large error messages, or does everyone have to see it? I'm used to using paste type services.

eric.shao03:02:22

@tony.kay Finally the figwheel-prompt shows, thank you for your advice. The problem is my chrome’s vpn-plugin for sure. Whenever I disconnect that plugin the prompt will show.Thank you.

tony.kay03:02:36

@eric.shao whew…lucky guess 😉

tony.kay03:02:22

@macrobartfast You could use a github gist…if you think a small portion of it is sufficient, then putting it in a `` ` block is good

macrobartfast03:02:27

the support ticket feature isn't offering me the ability to walk back... offers 1 frame of 0, or 0 of 0, even after creating a number of to-dos...

macrobartfast03:02:36

standby for error message from chrome.

tony.kay03:02:14

it could be the code needs some kind of update. No one has touched that code for the better part of a year. Could be it is in need of some update love. The error may help

macrobartfast03:02:29

here's the error (sorry for the delay... getting up to speed on using gists for this):

tony.kay03:02:08

what is in your network tab

tony.kay03:02:11

any errors there?

macrobartfast03:02:51

no errors there

tony.kay03:02:59

this doesn’t look like an actual problem…it looks like underdocumented “how to use” and poor error handling in our code 🙂

macrobartfast03:02:07

btw, this is just something I'm checking out because it's cool... this is not a priority ;-D

tony.kay03:02:18

I’m guessing nothing is wrong with the code

macrobartfast03:02:32

I should be focusing on the videos, anyway.

tony.kay03:02:33

So, when you created a “support ticket” it showed an ID in the js console

tony.kay03:02:57

when you start the support viewer, you have to supply that ID as a parameter in the URL. yes, that

macrobartfast03:02:11

of course I want to see this totally sweet thing working, but I can wait!

tony.kay03:02:18

mmmm. is that the right ID?

tony.kay03:02:27

that sounds like an Om transaction ID

tony.kay03:02:33

I don’t remember using UUIDs for that

macrobartfast03:02:34

aha... let me get the log entry

macrobartfast03:02:53

[995.238s] [om.next] transacted '[(support-viewer/send-support-request {:comment "yoodle"}) (support/toggle)], #uuid "66227ac9-6894-456e-aa1f-4d012f4b0780"

tony.kay03:02:00

oh wait…the SERVER log

tony.kay03:02:09

not the JS log

macrobartfast03:02:19

no, probably my bad, lol

tony.kay03:02:21

the server will tell you what it created…use THAT ID 🙂

macrobartfast03:02:42

I am laughing at myself in this coffee shop, looking positively crazy

tony.kay03:02:00

the intentional use-case is the server would send you an email saying “support case such-and-such” with a clickable URL

tony.kay03:02:04

only the server needs to knwo the ID

tony.kay03:02:19

though I guess you could tell the user “Case ID #5 was submitted"

tony.kay03:02:59

The coolest thing about that feature is that it took almost no code to make it happen…the model of Om just makes it possible, essentially for free

macrobartfast03:02:29

it's freaking awesome

macrobartfast03:02:55

by the way, you said exactly what to do in the readme: '...a support ID in the server logs...'

macrobartfast03:02:13

I'm still getting 1 of 0 frames via http://localhost:3000/support.html?id=1006, but I should rebuild and restart everything as that may resolve this

macrobartfast03:02:44

I mean, I've been a bit rambunctious in setting all this up.

tony.kay03:02:14

yeah, it should work. The error you were seeing was because there was no data in the request…the code was written rather quickly…lots of important things to build. Examples sometimes get the short shrift

tony.kay03:02:24

so, the error isn’t very useful

macrobartfast03:02:35

but I will be eager to get it working at some point, as it's going to be super sweet to demo it.

macrobartfast03:02:37

it's a great selling point on using the stack for those for whom the other advantages of clj/cljs may be a bit foggy.

macrobartfast03:02:30

but for now, as I said, I'll keep going on the basics, using the videos, which I greatly appreciate.

tony.kay03:02:46

when you demo it, realize that there is a way to do the VCR with any js app: record the dom deltas at every event. There are even commercial products to do so. The cool thing about our approach is that you have the actual application state…you can actually fix bugs against the figwheel-run support viewer and watch the user’s error disappear from the view they were looking at

tony.kay03:02:52

Talk about the ultimate in “error case reproduction"

tony.kay06:02:24

Just FYI: on SNAPSHOT I just fixed a bug in routing-tree. That function was not shown in the devguide, but I’d added it for easier use, but messed up on its implementation. Should not affect you if you’re using the devguide, but will affect you if you found it and used it.

tony.kay08:02:40

@baris @darrellesh The develop branch of untangled-ui now has a devcard showing a simple full stack form. It starts out loading multiple things from a server (which have not been augmented with form support). It then lets you click on them from a table display, initializes them into the form support, and let’s you edit. It also demonstrates simple full-stack updates. See form-demo-cards https://github.com/untangled-web/untangled-ui/blob/develop/src/guide/untangled/ui/form_demo_cards.cljs

tony.kay08:02:24

The main things that are still missing from form support: 1. more documentation/examples 2. more built-in form components (only have text field and dropdown written…oh, and checkbox I think) 3. maybe a built-in “vertical form” render that can generate a full-blown UI for you with some stock look-and-feel as a convenience when you want something that just looks like a standard form. 4. More built-in validations (1) is already decent, but incomplete. (2) and (4) are made to be extensible, so the existing examples are sufficient for any serious user. (3) is a nice-to-have, but most ppl will use it as a placeholder or example for making their own reusable declarative form generators.

tony.kay08:02:42

If you’re going to use form support “for real”, then I’d suggest becoming a contributor of the things you immediately need in (2) and (4). (3) requires that we finish the UI stuff in general.

baris10:02:51

@tony.kay for sure about 2 and 4. The current state of the forms component is nearly complete for me, just missing some few things like the capability for file (images) uploads.

baris10:02:47

I totally agree with you about 3. It's an easy step when the basic ui components are finished. The entire untangled story gets so powerful after that and I'm looking forward to that.

torkan16:02:30

Hi! Just starting out with Untangled/Om Next here, and I’m trying to ascertain best practices from the get-go.. When creating for example a LoginForm-component, is the preferred way to get the values of the subcomponents (eg username/password) through using om.dom, setting :ref’s on those subcomponents and then accessing the values through om.dom/node?

torkan16:02:11

In plain React, the preferred pattern would be to create some local state in the main component, and add onChange-listeners in the subcomponents to update the main component’s state, which would bypass the need for react refs

torkan16:02:10

And most of the docs/tutorials I’ve seen so far are about more advanced topics, regarding the app state and the reconciler etc 🙂

tony.kay17:02:42

@torkan So, it is different than that. Neither is the answer. The answer is that Om Next/Untangled require you do some understanding up front of the overall model. It may sound “more advanced”, but in fact the overall model makes everything simpler. It does require more learning up front. The Quick Introduction in the Untangled Dev Guide is your best bet

tony.kay17:02:16

@baris File uploads…hoping the image library component helps people see how to build that if the one we supply isn’t enough. We’ll get the docs out on the new modular server support ASAP.

torkan17:02:37

@tony.kay Thanks for replying 🙂 I’ve run through most of the devguide (at least up to section G), so I have the main concepts about the app state pretty much down, I was thinking that this is the sort of use-case where you don’t want to update the app-state on every keypress by the user, and should rather rely on local state

tony.kay17:02:24

Ah, I see. That is a very common question. Yes, component local state is there, and you can use it if you’re experiencing performance problems with something that updates rapidly.

tony.kay17:02:43

defui makes a standard React component that can use the complete set of React features

torkan17:02:54

However, I have failed to see an example that handles an input field in that way in your docs, or in Om Next’s, I might have just missed it though 🙂

tony.kay17:02:01

But, as soon as you break away from the app state, you lose your ability to see those interactions in the support viewer.

torkan17:02:58

Yeah, the reason I don’t want to put it in the app state, is precisely due to this, seeing every state update due to filling in fields are probably not that useful

tony.kay17:02:06

So, for example, in untangled-ui (not quite officially released yet) there is form state support. That feature would not be nearly as clean if the form data wasn’t being completely managed at the app-state level.

torkan17:02:10

(in the support viewer)

torkan17:02:40

Ah ok, so putting it all in the app-state is the way to go after all then?

tony.kay17:02:06

We’ve talked about “compressing history” as well, where transacts could be labeled as compressable, and more than one of those in sequence could be elided from the history on support requests.

tony.kay17:02:31

Also, you cannot visually regression test components if the state isn’t coming through props

tony.kay17:02:55

they are no longer pure functions

tony.kay17:02:29

so, I use component local state rarely. One example might be a graphical representation (e.g. drag n drop) where it is just too slow otherwise

torkan17:02:42

Yeah, that would be super-useful… I’ve used both Redux DevTools and Redux-form (which handles all form state through the redux state object)… Redux DevTools has a filter feature that basically allows you the same functionality

tony.kay17:02:58

so, only give up the benefits of pure rendering when performance won’t let you do anything else

tony.kay17:02:26

Yeah, these ideas are catching on everywhere. Immutable state and pure rendering rock

torkan17:02:00

Yup, that’s the main reason I decided to build my next project with Untangled, achieving all these concepts comes much more naturally and unforced with cljs/om/untangled, doing it in JS is a lot more cumbersome

torkan18:02:34

What is the current state of untangled-ui? Still relatively safe to start using, even though it’s not officially released yet, or?

tony.kay18:02:31

So, untangled ui is in a bit of flux as far as the CSS and wrappers go. The forms support isn’t changing (but may have bugs…and is missing stuff as described earlier). The image library works but is undocumented.

tony.kay18:02:05

It is on clojars in a SNAPSHOT form. I don’t plan to rename things, but argument lists might change slightly or expand.

tony.kay18:02:33

So, “safe to use” is “yes”, as long as you’re willing to tweak as we go.

tony.kay18:02:23

for example, we changed our minds on elements/ui-button on friday, and change the arglists and CSS to support more pure semantics so the CSS could be more easily themed and the API could be a bit more natural for the programmer.

tony.kay18:02:41

The layout responsive grid stuff is solid (but will get richer). The media selector stuff is also solid in layout/rwhen

tony.kay18:02:12

We’ve removed the inclusion of the generated CSS from Git (as should be the case for generated files). So you have to use the README.css instructions to generate it.

tony.kay18:02:51

The JAR generation story will include a build of it that will package the default CSS, but that is on the TODO list

tony.kay18:02:09

mostly we expect people will want to edit the settings and generate app-specific themed CSS

tony.kay18:02:30

We’re also toying with dropping the external CSS altogether and moving to co-located CSS generated dynamically with the components. Then you’d configure the theme via CLJS variables and we can get rid of all of the crap necessary to make the external CSS.

torkan18:02:19

Cool! I’ll check it out then 🙂

tony.kay18:02:58

that’s a bit off in the future, but it would have some cool advantages.

tony.kay18:02:15

So many things for aspiring OSS contributors to help with 😉

torkan18:02:02

One caveat with the css module approach (at least if you are creating hashed classnames etc), is that you require a full rebuild if you have an app that is to be shipped with various themes

tony.kay18:02:36

The themes are variable settings that are evaluated at runtime

torkan18:02:48

Could probably be solved with some fancy server-rendering which sets everything up first I guess, I haven’t looked into that stuff yet 🙂

tony.kay18:02:51

Theming could just update those values and re-emit the CSS to the DOM

tony.kay18:02:56

not server-side at all

tony.kay18:02:14

It just becomes part of your minified JS file

tony.kay18:02:30

and the CSS would be data, which isn’t rewritten by Closure

torkan18:02:28

Got it… We tried out the module approach for one of our apps at work, it became a little tedious as we have multiple instances of the same app for different customers (with different theming), and we basically have to rebuild everything if we just did some minor css updates

tony.kay18:02:39

well, depending on the change, this would require you to recompile the app (since the CSS is in the app)

torkan18:02:54

This presupposes that you don’t want to burden the client with a lot of unused css of course 🙂

tony.kay18:02:59

if it were just color changes/font/spacing, then you could easily use js variables (set in the header before load) to theme and have your cljs read those as the settings

tony.kay18:02:15

imagine instead of ’blue using something like js/color

tony.kay18:02:03

the local-kw helper just namespaces the class to the component

torkan18:02:05

Yeah, it’s unfortunately more cumbersome than that, so we ended up with just building separate css-files, and have the deployment-scripts pick a css-file to include in index.html depending on the instance

tony.kay18:02:47

ah, well, when your requirement complexity exceeds the abilities of your tools...

tony.kay18:02:23

find a way to convince the sales people/clients of a simpler solution 🙂

torkan18:02:45

Haha yes, the permanent state of any front-end dev 🙂

tony.kay18:02:53

e.g. do you really need that insignificant tweak to the look that costs twice as much?

tony.kay18:02:09

well, if you put $$$ to it, a lot of times they’ll agree

tony.kay18:02:21

“Yes, we can do that, but it’s $$ more"

tony.kay18:02:11

Usually these are process/people problems. You can only solve those with non-technical means…e.g. track exactly how much it is costing the company, and make that known to the accountants. They’ll want to pass that along via sales, which makes the sales guy want to sell it differently

tony.kay18:02:42

unfortunately, that usually happens after you’ve already signed contracts that have doomed you to suck-dom

torkan18:02:44

For our situation, it’s that we are one of the biggest universities in the country, and we provide a set of services for both ourselves and a lot of other academic institutions… And all those institutions of course already have a general theming to all their online services, so we have to adhere to them 🙂

tony.kay18:02:02

Ah. Well, that does make it harder

torkan18:02:30

Yeah, they pay for it though, it’s just that we have to ensure we have a sensible way of serving tailor-made css to all of them, and avoiding the inclusion of all of the irrelevant themes in the builds

torkan18:02:06

But you’re using the BEM-approach so far in untangled-ui, so it’s all good 🙂

tony.kay18:02:31

Yeah, our CSS guy is pretty good, and we’re trying to make everything easy to augment. Everything allows the addition of your own CSS classes alongside the ones the helpers (like ui-button) add

torkan18:02:36

I’ll try it out, looks good (like the rest of Untangled)!

tony.kay18:02:08

Thanks. It’s getting there

nha22:02:50

Speaking of om-css, are there plans to make is available in #?(:clj ..)? Thanks for the dev guide by the way, most approachable resource to learn om 🙂

tony.kay23:02:27

@nha the library is tiny (126 lines of code). It would take very little time to make it ss rendering compatible. Not using it at the moment. The whole om-css things was more of a side thought that you could easily do without a library, but be glad to take a PR.