Fork me on GitHub
#untangled
<
2017-01-05
>
tony.kay00:01:43

no cellophane....just Om Next v alpha45+

tony.kay00:01:07

and untangled client v 0.6.2-SNAPSHOT

tony.kay00:01:17

then yes, a cljc file.

tony.kay00:01:21

The #js thing requires data-readers, which is in Om next. I've seen it have problems with that...might ask on the Om channel. Really all you need is a data_readers.clj file that has the line {js clojure.core/identity} I think

tony.kay00:01:49

anything with a # in front of it is an EDN tag meant to trigger a reader. Setting the js reader to identity on clj will do it

tony.kay00:01:09

but Om should have already done that...might try a clean and restart of everything, and make sure latest version of Om/cljs

tony.kay00:01:00

At one point I just changed #js to (clj->js { ... }) and put a #?(:clj (def clj->js identity)) at the top of the file

tony.kay00:01:20

but again, you can do that via data readers

sova-soars-the-sora02:01:27

Okay, Thanks a lot @tony.kay I am wondering... how can I know the latest versions available for cljs and also om.next?

sova-soars-the-sora02:01:10

@adambros Why thank you sir, that is excellent.

sova-soars-the-sora02:01:27

(dom/render-to-str) does not appear to exist in om alpha 45, but 46 is good. just fyi

sova-soars-the-sora02:01:49

or maybe I spoke too soon.. hrm.

sova-soars-the-sora02:01:30

`#object[ReferenceError ReferenceError: ReactDOMServer is not defined] ReferenceError: ReactDOMServer is not defined`... Will snoop. any thoughts in the interim?

exit214:01:03

Anyone here familiar with this error? Uncaught Error: Assert failed: (or (component? x) (reconciler? x))

danielstockton14:01:46

@njj it's quite common when i'm doing something wrong.

danielstockton14:01:52

Look at the stacktrace, it should tell you where the problem is.

tony.kay16:01:45

@sova I'm using alpha47...perhaps it is fixed in later versions

tony.kay16:01:08

@njj just means you passed something that was neither a component or reconciler to something (like transact!) that wanted a component or reconciler

exit216:01:44

(defroute foo-routes "/foo/:bar" [bar]
  (transact! @reconciler [(app/choose-tab {:tab :search})
                          (search/new-query {:status bar})
                              :ui/root]))
I’m passing the reconciler in this case

tony.kay16:01:27

my guess is you don't have what you think you have...perhaps that is an untangled app instead?

tony.kay16:01:55

in which case (:reconciler @app)

tony.kay16:01:23

(js/console.log @reconciler)

exit216:01:31

perhaps the issue is: (def reconciler (atom nil))

tony.kay16:01:00

possibly 😉

exit216:01:40

this app was setup by a peer of mine who abstracted quite a bit, so unfortunately the documentation isn’t 1 to 1 w/ what i’m looking at

tony.kay16:01:57

yeah, and your peer is still wrong in not quoting the transact data

exit216:01:06

Im gonna switch to om/transact versus his transact abstraction

exit217:01:00

@tony.kay I was able to get things working based off your todomvc example

exit217:01:34

@tony.kay When using the quoted transaction vector, how do I parse params passed in from defroute?

exit217:01:59

it appears that is turning that param into a string, i.e. “bar” versus whatever param is passed in the actual url

tony.kay17:01:35

read up on syntax quoting. In short:

(om/transact! r `[(app/f {:p ~arg})])

tony.kay17:01:56

a backquote is a syntax quote...makes things literal. ~ is unquote

tony.kay17:01:17

unquote lets just the thing that follow it come from the env outside of the quoted thing

exit217:01:18

(defroute foo-routes "/foo/:bar" [bar]
  (om/transact! @reconciler `[(app/choose-tab {:tab :search})
                             (search/new-query {:status ~bar})
                            :ui/root]))

exit217:01:20

something like this?

tony.kay17:01:56

single-quote is literal literal

exit217:01:15

I’m a JS dev, learning CLJS this is my first project w/ it

exit217:01:30

somethings like that were hidden from me, I guess to prevent having to explain it 🙂

tony.kay17:01:39

cool. Clojure for the Brave and True is a good online resource

tony.kay17:01:54

quoting is leveraged mainly in macros

exit217:01:37

thanks again @tony.kay - really loving untangled

tony.kay17:01:46

welcome. Glad you like it.

exit217:01:01

@tony.kay have any examples that don’t use hash routing and doesn’t case a full page reload?

exit217:01:16

I feel like thats what this is for.. https://github.com/venantius/accountant

tony.kay17:01:30

I do not. Not really a concern of the framework itself. More about how you want to set up your app.

tony.kay17:01:30

From my perspective, I really think "back" and "forward" should be no-ops in SPA. If you're writing an application on the desktop you don't have a "back button". Why should we have one just because it runs in a browser? Makes software a lot more complicated. We spend countless hours worrying over it, doing it poorly (because it is basically not cleanly solvable), and not adding the actual useful features users really need. Who is going to not use your product because back is a no-op, but your real features rock? Has anyone honestly stopped using a webapp because back didn't "undo" their prior operation? Does "back" in gmail compose/send unsend your message?

tony.kay17:01:55

If you're browsing stateless documentation, sure...if you just pressed a button that executed a transaction on the server? WTF?

tony.kay17:01:04

what is back gonna do?

tony.kay17:01:23

I think we're doing ourselves a disservice by trying to map stateless doc browsing onto an application

tony.kay17:01:06

I lean towards disabling back/forward, and just warn that page reloads are not what you want when you try them

tony.kay17:01:26

Direct navigation to some part of the app seems OK, but the use is rather limited. I can see the benefit of being able to target part of an app from, say, an email link.

tony.kay17:01:13

stepping off soap box now 😉

exit217:01:11

catching up here 😄

exit217:01:10

@tony.kay how about no back button, but clicking a link like /foo/bar doesn’t require a full page reload?

exit217:01:14

or is that sort of the same..

tony.kay17:01:29

why do you need the URL to change? Why does it need to be a link at all?

tony.kay17:01:36

it's an SPA

tony.kay17:01:42

make the button change the state, which changes the view

exit217:01:50

bookmarking mostly

tony.kay17:01:52

no linking involved...it ISN'T documentation

tony.kay17:01:57

can you bookmark Excel?

exit217:01:12

its an internal tool, people want to be able to share links

tony.kay17:01:18

it's trying to map a stateless doc concept onto an application

tony.kay17:01:37

I understand. I know people write up requirements that way.

tony.kay17:01:42

Yes, you can do it

tony.kay17:01:54

I thought you already had that part, though

tony.kay17:01:09

you should not be seeing full page reloads from, say, todomvc

tony.kay17:01:17

the item filtering is done via URL

exit217:01:44

but todomvc uses hashroutes no?

tony.kay17:01:04

Yeah, you have to configure the browser to do that

tony.kay17:01:22

again, not part of the framework itself, just standard HTML5 routing setup

exit217:01:45

ya its basically like “#/foo” works in my current setup, but we want just “/foo” type thing

exit217:01:05

cool I’ll look into it, I’ve seen it done in Angular, React, etc.. I believe

tony.kay17:01:18

the google closure library is automatically available

tony.kay17:01:40

accountant hacks in that way, I think

tony.kay17:01:31

The one thing you'd have to fix though, is that you have to get the server to serve your index page independent of what URL it is asked for

tony.kay17:01:49

cause otherwise if someone starts with that link, then the server will say page not found

exit217:01:09

cool, so it should just be able to be done by setting it up w/ html5history correctly and telling secretary not to use hash routes

tony.kay17:01:40

and making sure the server will server index.html when asked for any URI

tony.kay17:01:54

(except /api, which is your untangled API channel)

therabidbanana17:01:51

We use pushy combined with bidi for URL routing. We need it for sharable/bookmarkable dashboards. I think it's an overreach to say SPAs in general don't need routing, but yeah, for the most part we only route the stuff that might be bookmarkable, not every single action.

exit217:01:40

@therabidbanana does your setup use secretary at all?

therabidbanana17:01:52

No - I think bidi takes the place of that

exit217:01:58

ok interesting.. thanks

exit217:01:18

I definitely need shareable/bookmark-able for the same reason as you

tony.kay18:01:44

Thanks @therabidbanana . I agree that some things like that are needed. Like I said, more of a soap box sore spot 🙂

therabidbanana18:01:31

Basically you hook up pushy to call a function on every route change, in our case it's basically just a direct call to om/transact! - but we have it tack on other actions besides (route/update) based on url (for example, some data we don't pull until you jump into a specific dashboard, so if you hit a dashboard route we can tack on an (untangled/load) in the transaction

exit218:01:21

@therabidbanana have an example you can share of the direct call on transact? I suspect my setup would be similar

therabidbanana18:01:13

So the key bit of code is in the update-fn we call in mount. mount is called with the reconciler during app initialization.

therabidbanana18:01:52

Handlers is the bit with the extra info to tack on to route transitions for untangled lazy loads.

exit218:01:01

:thumbsup:

therabidbanana18:01:08

Looks like pushy takes two functions when you initialize it - one for what to do on a match - update-fn, and one to transform url to match parameters that get passed into the update-fn, which we call url->route

therabidbanana18:01:54

To be fair to @tony.kay though - we needed routing as much to prove untangled could stand up to Ember.js as we did for actual usage of the feature. In general we probably have more routes than we need. 🙂

exit218:01:29

@therabidbanana I was able to drop pushy in my project w/ existing code around secretary and have no hash routes 😄

exit218:01:22

btw @tony.kay I forgot to mention, the project I’m working is with jason jackson

exit218:01:26

he said you might know him

tony.kay18:01:32

@therabidbanana ah yes...must have routes in Ember, else we might forget where to pee

therabidbanana18:01:48

Pretty much yeah

tony.kay18:01:54

@njj sure! we've interacted a decent amount

exit218:01:22

haha re: Ember

exit218:01:34

it was like their #1 thing in that first instructional video

exit218:01:46

YOU MUST HAVE ROUTES, OTHERWISE CHAOS

jasonjckn18:01:38

there's now 3 engineers and 1 project manager on our untangled app 🙂

tony.kay18:01:26

we're spinning up a staff of about 20

therabidbanana19:01:21

Well, to be fair to Ember, the router is Ember's version of the reconciler - a single source of truth in charge of the hard getting/synchronizing data stuff. The fact that it's tied to urls is more of a byproduct of just trying to have some reliable abstraction like that.