vrac

Template-based web library [WIP] - https://github.com/green-coder/vrac Zulip archive: https://clojurians.zulipchat.com/#narrow/stream/180378-slack-archive/topic/vrac Clojureverse archive: https://clojurians-log.clojureverse.org/vrac
tianshu 2019-12-19T13:50:02.000400Z

Hi

tianshu 2019-12-19T13:50:58.000700Z

@vincent.cantin we can continue here

2019-12-19T13:51:29.001300Z

Welcome in the chan, you are litterally the first one to show interest in the details of Vrac.

tianshu 2019-12-19T13:51:37.001500Z

Yeah, I see

tianshu 2019-12-19T13:53:24.003400Z

(for [c cars]
  [car-component c])
if c is {:car/id 1}, maybe it is possible to do [car-component (assoc c :some/prop some-val)]

tianshu 2019-12-19T13:53:47.004Z

this make the inference basically impossible imo.

2019-12-19T13:54:24.005Z

in this snippet, nothing more should be assumed about cars than the template says.

2019-12-19T13:54:40.005400Z

It means that it is kind of generic

tianshu 2019-12-19T13:55:04.006Z

can you explain more about this?

2019-12-19T13:55:22.006400Z

Let me copy/paste some of my recent code sample …

tianshu 2019-12-19T13:55:32.006600Z

okay.

tianshu 2019-12-19T13:56:12.007200Z

btw, I also have some code when explore https://github.com/DogLooksGood/fullstack-explore/blob/master/src/fullstack_explore/app.cljs this is what I get for now

2019-12-19T13:57:38.007400Z

2019-12-19T13:58:12.008Z

I don’t specify any type anywhere, no need

2019-12-19T13:58:41.008600Z

I only specify the fields used. That’s the same as Pathom which does not care the types

2019-12-19T13:59:43.009600Z

I will need to find how to have automated data normalization at some point, but I may not necessary follow the Fulcro way for that.

2019-12-19T14:00:26.010300Z

I hope to have the user say as little as possible and deduct evething I can from how the data is used.

tianshu 2019-12-19T14:01:10.011100Z

so, basically when you say (:session/title session), you got [:session/title] in the query?

2019-12-19T14:01:50.011800Z

Yes, it means {session [:session/title]} for Pathom.

tianshu 2019-12-19T14:02:33.012400Z

what if I use (str/upper-case (:session/title session)) ?

2019-12-19T14:03:06.013Z

that’s a function call, that’s not data being dereferrenced

2019-12-19T14:03:30.013500Z

it would not matter for the extracted data query

2019-12-19T14:03:56.013900Z

parsing the argument of the function call would.

tianshu 2019-12-19T14:05:18.014400Z

how you know about the ident, I think that is the point how you normalize data.

tianshu 2019-12-19T14:05:46.014600Z

{:id :coscup/session}
oh i see

tianshu 2019-12-19T14:07:12.015600Z

I also curious about the rendering strategy, will you use react?

2019-12-19T14:09:25.016500Z

I want Vrac templates to encode semantics and be decoupled from any rendering tool.

2019-12-19T14:10:30.017800Z

At the same time, I need to render things .. so my plan is to support React, then support other tools which may have a better performance. The user will have the choice.

2019-12-19T14:13:11.017900Z

This part is not fully defined in my head, but I may try to decouple the UI and the normalization. The state logic needs to know about normalization, not the UI.

tianshu 2019-12-19T14:18:21.019Z

Is that if, for block in template still meaningful if using react?

2019-12-19T15:12:20.020200Z

@doglooksgood {:id :coscup/session} is not used for normalization. That’s just the component’s id, it is not related to the data.

2019-12-19T15:13:33.021100Z

the if and the for are meaningful for React, you need to implement their semantic when you render the template via React.

2019-12-19T15:14:47.021900Z

so far, Vrac only supports the if, when, let and for directives

tianshu 2019-12-19T15:16:50.022800Z

why? you mean, for example, an if block is a react component?

2019-12-19T15:17:31.023300Z

That would be a overkill. a JS if would be good enough.

tianshu 2019-12-19T15:18:10.023700Z

I see, so for the react renderer case, the dsl can be treated as just code

tianshu 2019-12-19T15:18:37.024200Z

but for some renderer, you can do render like svelte

2019-12-19T15:19:40.025300Z

I may add support for Javelin and Hoplon as renderer later (in 6~18 months?)

tianshu 2019-12-19T15:20:49.026Z

how do you expression initial-state, do you think it is necessary?

2019-12-19T15:21:45.026600Z

no opinion for now

2019-12-19T15:23:54.028100Z

the component being just data, one can add a field for initial-state in their component and use it himself to build some initial data. No need to have Vrac do anything about that.

2019-12-19T15:24:37.028900Z

I use clojure’s spec to parse the template and the specs are open to additional data - thanks to Rich Hickey’s wisdom.

tianshu 2019-12-19T15:25:26.029100Z

oh, great

2019-12-19T16:56:42.031100Z

@souenzzo if I wanted to compare vrac with existing frameworks, it would be close to vuejs for the templating and close to fulcro for the usage of eql

souenzzo 2019-12-19T17:07:55.037800Z

Hello 🙂 I'm working on inga , that from "mainstream" libraries, looks like CakePHP Scaffolding In practice, it's inspired on Direct2Web module from WebObjects(NeXTStep/Apple), that was used and appreciated here at the company where I work https://gist.github.com/souenzzo/113795e3a7ce069417e5cb83c99aee9b It aims to be declarative and dynamic. We want just to say "this page will show X Y and Z" and it should be ready. We can extend it with 2 concepts (from D2W): • task: task says "what I want to do". By default there is "task/query" and "task/mutation". On D2W, there is 4 tasks by default: CreateReadUpdateDelete • ui: ui tays "how to show data". By default there is "ui/query" and "ui/mutation". You can extend and create a new "ui/my-custom-query" Everything should be extended via resolvers

👍 1
2019-12-19T17:18:22.038600Z

in vrac, eql queries and renderers are derived from the template

2019-12-19T17:19:02.039300Z

mutations are not part of the library, vrac mostly focuses on data loading and display at the moment.

2019-12-19T17:19:50.039800Z

it’s supposed to be used as a library, one piece in the puzzle

2019-12-19T17:20:44.040100Z

Nice to meet you