untangled

NEW CHANNEL: #fulcro
gardnervickers 2016-10-11T01:47:28.002190Z

If I use data-fetch/load-data from within a component, the doc’s say it places a loading marker in place of the components props, but I’m not seeing that. Should I be querying for :ui/loading-data on the component like with data-fetch/load-field?

tony.kay 2016-10-11T05:13:03.002193Z

@gardnervickers We need to improve the docs on that a bit. There are a couple of things. By default load-data does put a load marker in place, but in the place of the data being queried. load-field will put the marker in place of the field being loaded. Since load-data loads data into the top-level app state, the marker actually is placed at the first property in the query at the root

tony.kay 2016-10-11T05:14:11.002194Z

So, (load-data this ‘[:x]) will put the load marker as if you did an assoc-in at [:x :ui/fetch-state] in the app state.

tony.kay 2016-10-11T05:14:52.002195Z

load-data on [{:x [:y]}] will do the same

tony.kay 2016-10-11T05:15:17.002196Z

as will [{:x [:y]} :z]. In the latter case, nothing appears at :z

tony.kay 2016-10-11T05:15:58.002197Z

we should probably extend this functionality a bit to allow you to place the load marker in a spot of your choosing, since you might be doing a post mutation to move it into place after the load.

mitchelkuijpers 2016-10-11T08:21:57.002200Z

@tony.kay +1 for moving the marker it would make my life a bit easier

gardnervickers 2016-10-11T09:17:15.002201Z

@tony.kay: ah great thank you that makes sense

dilvan 2016-10-11T11:03:42.002205Z

Does Untangled support using DataScript with Om Next? I know it doesn't support DataScript queries (they are slow), but can I still use a DataScript db?

gardnervickers 2016-10-11T12:01:14.002206Z

@tony.kay For my data-fetch/load-data, it’s sufficient to just supply and :ident and :marker true, right? I’m seeing the data load marker being placed under {nil {:ui/fetch-state {…}} in the app state instead of on the first element of my query.

gardnervickers 2016-10-11T13:04:06.002207Z

It appears that when you’re loading component has an ident set and it’s a load-data (without a field specified), then (data-field state) is nil here. https://github.com/untangled-web/untangled-client/blob/master/src/untangled/client/impl/data_fetch.cljs#L292

mitchelkuijpers 2016-10-11T13:18:23.002209Z

@gardnervickers which version are you running of untangled-client?

gardnervickers 2016-10-11T13:18:58.002210Z

0.5.8-SNAPSHOT

gardnervickers 2016-10-11T13:19:01.002211Z

it’s a checkout from master

mitchelkuijpers 2016-10-11T13:19:26.002212Z

Oh ok, I don’t think you want to use :ident

mitchelkuijpers 2016-10-11T13:19:50.002213Z

that is to make a join on something. (it makes load-data basically load-field)

gardnervickers 2016-10-11T13:20:15.002214Z

What should I do if I want to “refresh” the data on a component then?

mitchelkuijpers 2016-10-11T13:20:24.002215Z

At least that is how I interpreted it

mitchelkuijpers 2016-10-11T13:21:43.002216Z

Don’t you want to use :refresh ?

gardnervickers 2016-10-11T13:23:41.002217Z

I meant refresh as in re-run the components data fetch

2016-10-11T13:25:09.002218Z

@dilvan: no, you must use Om's default db format with untangled. But we have added a ton of structure to make it easier to use than stock Om next. For example, you don't have to build a read parser

mitchelkuijpers 2016-10-11T13:27:12.002219Z

You can just run a refresh from a user action (a mutation)?

mitchelkuijpers 2016-10-11T13:28:03.002220Z

I am sorry I don’t really get your question @gardnervickers

gardnervickers 2016-10-11T13:31:28.002221Z

The issue I’m running into is that from what was mentioned above by Tony, a load-data on a component should place the loading marker on the first element of the components query. With that, a component with a query [:a :b :c], load-data on that should swap out :a for the loading data marker map (so I can use it with lazily-loaded, etc..). What I’m seeing instead of that is the function that places the marker is not swapping out the value of :a for the load marker, but is associng the load marker onto the key nil.

gardnervickers 2016-10-11T13:33:45.002226Z

Sorry, butchered that ^

2016-10-11T13:34:38.002227Z

@gardnervickers: are you parameterizing the query? Or using a post-mutation? We had a bug like that a couple weeks ago, thought that we had fixed it

gardnervickers 2016-10-11T13:34:51.002228Z

Nope, neither

2016-10-11T13:34:57.002229Z

Hm

gardnervickers 2016-10-11T13:35:34.002230Z

https://github.com/untangled-web/untangled-client/blob/master/src/untangled/client/impl/data_fetch.cljs#L290 It’s because I have an :ident I think

2016-10-11T13:36:11.002233Z

@mitchelkuijpers: the refresh keyword tells the UI what to re-render, it doesn't trigger a new data fetch on its own

gardnervickers 2016-10-11T13:36:46.002234Z

(data-field state) would return nil because I don’t have a field I want to load. Presumably this should be the first key in the query.

2016-10-11T13:38:15.002235Z

Yeah but I still wouldn't expect it to show up at the top level of app state

2016-10-11T13:38:49.002236Z

In any case I'm not sure that the Ident and field parameters are intended to be used separately -- I think we assume that they are always used together

2016-10-11T13:39:52.002237Z

Yes, otherwise normalization could fail

gardnervickers 2016-10-11T13:42:39.002238Z

Just to confirm what I’m seeing because you mentioned the “top level of app state”. For query [:a :b :c], I see (under the proper ident in my table when using :ident) {:a … :b … :c … nil <load-marker>} instead of {:a <load-marker> :b … :c …}

gardnervickers 2016-10-11T13:44:57.002239Z

I’m fine writing my own version of load-data if this is not the intended use for it too, just wanted to make sure 😄

2016-10-11T13:47:36.002240Z

Not sure I understand. Is you query [:a :b :c] or [{[:my :ident] [:a :b :c]}]

2016-10-11T13:47:52.002241Z

because if you are using the :ident parameter in your data load, then the latter is what is being formed

gardnervickers 2016-10-11T13:48:10.002243Z

Yea that’s correct, the latter is the query that’s being answered by the server

2016-10-11T13:48:33.002245Z

Yeah I’m not sure that data fetch supports that

2016-10-11T13:49:00.002246Z

although you’re right, based on the doc string and syntax it seems like it should

2016-10-11T13:49:08.002247Z

let me double check

gardnervickers 2016-10-11T13:49:14.002248Z

I mean it does correctly fetch the data, just the marker is placed incorrectly

2016-10-11T13:50:17.002249Z

yeah I believe it correctly fetches the data, I’m just not sure that the marker/normalization plumbing anticipates that use case

gardnervickers 2016-10-11T13:50:30.002251Z

Oh gotcha ok

2016-10-11T13:54:14.002252Z

yeah. not sure if it’s a bug or not but it appears to be an issue with the data-path function that you linked me

2016-10-11T13:55:43.002253Z

it assumes that a load-field is happening, whereas your case is closer to to load-fields (plural)

2016-10-11T13:56:04.002254Z

so the field key may be empty but the query key may be present

2016-10-11T13:56:35.002255Z

makes me think that instead of having a special field key in the data state, that we should just put it under query

2016-10-11T13:57:21.002256Z

I’ll have to do some digging to see how / if to fix this but don’t have time at the moment. @gardnervickers can you file an issue and copy this little 5 line rant into it?

gardnervickers 2016-10-11T13:59:51.002258Z

Sure

2016-10-11T14:01:13.002259Z

thanks

gardnervickers 2016-10-11T14:07:08.002260Z

So with load-field, we replace the value of the field we’re trying to load with the load marker. Does it make sense for load-data to replace the data at that “level” of the tree with the load marker? Similar to running load-field from the parent on the join that is created from our component’s query?

tony.kay 2016-10-11T14:55:58.002261Z

@gardnervickers probably not

tony.kay 2016-10-11T14:56:37.002262Z

there is no "level" in the database, and your load-data might be loading something that you have to post-mutate into place...meaning that your query might be unrelated to the triggering UI

tony.kay 2016-10-11T14:57:08.002263Z

At the moment we're primarily using load markers for fields, and the global :ui/loading-data (which can be queried from any component)

tony.kay 2016-10-11T14:57:35.002264Z

I'm not convinced it makes sense to make load-data work with markers at all, to be honest

tony.kay 2016-10-11T14:59:19.002265Z

Query for [[:ui/loading-data '_]] in any component and you can use that to show a busy indicator...but typically you'd show that in some globally visible location. If you want a component-specific marker, just put that in your app state manually (e.g. place a :ui/loading true in the state of the component you're working with, and have your post mutation remove it)

tony.kay 2016-10-11T15:00:00.002266Z

The load marker support in Untangled is a really simple convenience, and if we can make the API more generally useful we will, but all of these cases are actually pretty simple to implement with the base primitives we've supplied

gardnervickers 2016-10-11T15:01:17.002267Z

Sounds good, thanks for the well thought out reply, as always it's appreciated!

tony.kay 2016-10-11T15:01:34.002269Z

sure...I'll change your issue to a feature request (enhancement)

tony.kay 2016-10-11T15:01:52.002270Z

I think I see a way to make the API clearer...others are going to want similar things

mitchelkuijpers 2016-10-11T15:04:27.002271Z

I am working with devcards is there a particular example that would be helpful?

tony.kay 2016-10-11T15:04:38.002272Z

?

tony.kay 2016-10-11T15:04:45.002273Z

The entire tutorial?

tony.kay 2016-10-11T15:04:51.002274Z

🙂

mitchelkuijpers 2016-10-11T15:04:51.002275Z

I am almost at the point where I would like to run some mocked server transaction

tony.kay 2016-10-11T15:05:04.002276Z

Look at the Putting It Together section

mitchelkuijpers 2016-10-11T15:05:08.002277Z

Aha thnx

mitchelkuijpers 2016-10-11T15:05:17.002278Z

I should really do that tutorial lol

tony.kay 2016-10-11T15:05:18.002279Z

it has you write a full-stack example using a real server, but runs the UI in dev cards

mitchelkuijpers 2016-10-11T15:05:49.002281Z

Oh that is exactly what I am looking for

mitchelkuijpers 2016-10-11T15:08:29.002282Z

Awsum

tony.kay 2016-10-11T15:08:57.002283Z

yeah, the app state viewing is so sweet

tony.kay 2016-10-11T15:09:17.002284Z

I like putting a delay into the server, just so I can watch the network magic 🙂

tony.kay 2016-10-11T15:09:43.002285Z

Though it reveals a few "unclean" things in the current implementation...some cruft gets left around

tony.kay 2016-10-11T15:09:51.002286Z

harmless, but ugly

mitchelkuijpers 2016-10-11T15:14:25.002289Z

Yeah I want to make myself create stuff in devcards and then just drop it in the application, it feels like a way better approach to developing

mitchelkuijpers 2016-10-11T15:14:45.002290Z

But the printing of the app state alone saves a lot of time

tony.kay 2016-10-11T15:14:55.002291Z

assuming your app state isn't too big

mitchelkuijpers 2016-10-11T15:15:44.002292Z

Yeah but we mostly try to create small modulair parts

mitchelkuijpers 2016-10-11T15:15:53.002293Z

and then put it together in the application

mitchelkuijpers 2016-10-11T15:16:10.002294Z

Really cool stuff

tony.kay 2016-10-11T15:39:34.002301Z

thanks. I am really loving how it is coming together...still finding little improvements to make, but man it is nice to work with

tony.kay 2016-10-11T15:47:19.002302Z

note 0.5.8-SNAPSHOT @mitchelkuijpers

tony.kay 2016-10-11T15:47:36.002303Z

I have not released 0.5.8 yet, and it is needed to get the app state display in devcards

dilvan 2016-10-11T15:51:54.002305Z

Is there a way to use Material Design components with untangled (for instance, http://www.material-ui.com)? Can I also reuse javaScript components written for react.js?

tony.kay 2016-10-11T15:52:24.002307Z

yes

tony.kay 2016-10-11T15:52:28.002308Z

see Tutorial

tony.kay 2016-10-11T15:52:42.002309Z

hm...actually, @mahinshaw did you merge the advanced UI stuff yet?

tony.kay 2016-10-11T15:53:05.002310Z

Untangled (because it uses Om Next) is 100% compatible with vanilla React

tony.kay 2016-10-11T15:54:06.002311Z

Here's an example using Victory:

tony.kay 2016-10-11T15:54:44.002313Z

see https://github.com/FormidableLabs/victory-chart

tony.kay 2016-10-11T15:55:01.002315Z

I can't speak for specific other React libs....mostly the problem you might hit are build problems with module support

tony.kay 2016-10-11T15:55:34.002317Z

not specific to Untangled/Om

tony.kay 2016-10-11T15:55:50.002318Z

Some js libs are packaged in a way that makes them harder to "get at"

tony.kay 2016-10-11T15:56:36.002319Z

Maria has done work on that, but it isn't well-documented: https://github.com/clojure/clojurescript/wiki/Google-Summer-of-Code-2015

gardnervickers 2016-10-11T15:58:49.002321Z

We’ve been using NPM and webpack to make a bundle placing the libraries we need on the window object. Then, we generate the externs based on the external calls we use instead of generating them for the entire Javscript library

wilkerlucio 2016-10-11T15:59:55.002322Z

@gardnervickers can you share some of the configurations used for it? I felt the need to that a couple times but didn't got into the trouble of actually trying

wilkerlucio 2016-10-11T16:00:18.002323Z

when the library does already require react, it's possible to bundle excluding the react itself?

gardnervickers 2016-10-11T16:01:36.002324Z

@wilkerlucio This is an example of our webpack config file

const webpack = require('webpack');
const path = require('path');

const BUILD_DIR = path.resolve(__dirname, 'resources', 'public', 'js');
const APP_DIR = path.resolve(__dirname, 'src', 'js');

const config = {
    entry: `${APP_DIR}/main.js`,
    module: {
        loaders: [
            { test: /\.jsx?$/, loaders: ['babel-loader'], exclude: /node_modules/ },
            { test: /\.css$/, loader: "style-loader!css-loader"},
            { test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/, loader: 'url-loader?limit=100000' },
            { test: /\.less$/, loader: "style!css!less"}
        ]
    },
    output: {
        path: BUILD_DIR,
        filename: 'bundle.js'
    },
    resolve: {
        extensions: ['', '.js']
    },
    externals: {
        "react": "React",
        "react-dom": "ReactDOM",
        "react-bootstrap": "BS",
        "react-addons-shallow-compare": "React.addons.shallowCompare"
    },
    node: {
        fs: "empty"
    }
};

module.exports = config;
The important part is the externals, which allow us to supply our own React/ReactDOM implementations (from cljsjs).

wilkerlucio 2016-10-11T16:02:12.002325Z

humm, nice, I didn't knew about that feature

wilkerlucio 2016-10-11T16:02:54.002326Z

thanks @gardnervickers , I'll be trying that later today 🙂

mahinshaw 2016-10-11T17:09:03.002328Z

@tony.kay No, I haven’t. Ill get it in today

tony.kay 2016-10-11T19:58:52.002329Z

I've started working on issue #43 regarding load markers. Our data load code could use some refactoring and cleanup, which I'm also going to do. Just in case anyone out there is working on a patch that would conflict.

2016-10-11T23:07:19.002332Z

wooo :advanced optimized builds fixed itself

2016-10-11T23:07:28.002333Z

it use to be broken last time I tried it 2 months ago

tony.kay 2016-10-11T23:15:14.002335Z

nice to know, @jasonjckn . You should probably thank @anmonteiro

mahinshaw 2016-10-11T23:22:49.002337Z

@tony.kay I put up a PR for the advanced ui stuff

tony.kay 2016-10-11T23:53:35.002338Z

@mahinshaw just sent in a section on integrating React js components with Om/Untangled. Now available in the tutorial: http://untangled-web.github.io/untangled/tutorial.html#!/untangled_tutorial.M10_Advanced_UI