These are chat archives for ractivejs/ractive

11th
Nov 2017
Larry Osborn
@larryosborn
Nov 11 2017 04:56
I just came across the bind- directives for attributes in the change log. I spent the afternoon de-mustaching my templates. Very nice change!
Chris Reeves
@evs-chris
Nov 11 2017 04:59
:+1: I like that one too
kouts
@kouts
Nov 11 2017 16:15
@larryosborn hi, what is this change exactly where is in the changelog?
Chris Reeves
@evs-chris
Nov 11 2017 16:17
0.9.0 - two above new stable features
attr="{{foo}}" === bind-attr="foo" and attr="{{attr}}" === bind-attr
kouts
@kouts
Nov 11 2017 16:30
Ahh I have missed this, but why have 2 ways of doing the same thing? Mustaches inside attrs with standard names is one of the thing that sets Ractive apart from other MVVM libs, I hope this doesn't become the norm...
Larry Osborn
@larryosborn
Nov 11 2017 16:55
With components isolated by default now, I had a ton of places where I would pass <widget foo=“{{foo}}”>. Now they feel a lot cleaner with <widget bind-foo>.
Feels more consistent now that I’m also using similar style for class-something=“foo” instead of class=“{{#if foo}}something{{/if}}"
kouts
@kouts
Nov 11 2017 16:59
(Irrelevant to Ractive) Question: How do you handle page data fetching in your apps? Let's say you have a page with multiple sections, each one requesting it's own set of data from the backend.
In PHP world I would fetch my data from my Models combine them inside the Controller and then the controller would pass all the data to the View and render... Do you take a similar approach combining all data in a single response or do you query the backend multiple times?
Chris Reeves
@evs-chris
Nov 11 2017 17:03
Depends on how related the data is. Most of my micro-ish services return an object graph, so most of the relevant data comes in a bundle. There are some one-offs that get separate requests though, and those are typically stored separately in the app, as they're also relevant elsewhere.
I typically use postgres on the back end, and between json fields and a dao that can extract multiple models from a joined query or even a cte, it's usually pretty easy to glom everything together.
Joseph
@fskreuz
Nov 11 2017 17:08
@kouts iirc, bind- was one of the new additions that was met with mixed reviews because it departed from the traditional Ractive syntax (and ventured into Svelte/Vue territory). That's why it's there, but left undocumented... for now.
kouts
@kouts
Nov 11 2017 17:12
@fskreuz and @larryosborn I understand it's use in custom components now that I've given it a closer look.
@evs-chris by object graph do you mean lots of "different" data sets in the same object (payload)?
Joseph
@fskreuz
Nov 11 2017 17:13
re: combining data (and in context, I use Spring), initially I would have separate endpoints and DTOs for separate entities. But in cases where I need some data in bulk for a multi-thing page, I would have another endpoint and another DTO that combines that data for that specific case. I'd like to think of the approach like a DB "view", all data combined in one response but the interface is read-only.
kouts
@kouts
Nov 11 2017 17:20
ok so you combine the data server side (fetching from multiple endpoints) and you send one rensponse to the frontend, right?
(I'm always talking for whole "View" or "Page" payload)
Joseph
@fskreuz
Nov 11 2017 17:31
I usually only do this for monolithic data (like a profile page). Otherwise, multiple independent requests are fine (within reason). ymmv :grin:
Chris Reeves
@evs-chris
Nov 11 2017 17:43
by object graph I mean an array of same-in-out objects with their associated members already in place e.g. a list of machines that each have properties like make and model along with components like cpu, gpu, etc that have their own specs and possibly components
things that are managed separately in the database but come back bundled together from service endpoints
most stuff that I deal with uses internal services, so I don't typically have to worry about external service calls
Chris Reeves
@evs-chris
Nov 11 2017 17:48
usually when I do have to integrate with an external service, it's some government thing that is ancient and backwards or a third party proxy for one of those ancient backwards things that uses soap and an IP whitelist that requires me to proxy it from the back end anyway
at any rate, if the data is visible in the default view, I typically bundle it on the back end
if it's behind some sort of poke here for details ui and not super easy to gather, I'll pull it in from a separate request
ractive is also particularly good at handling relations internally with reference expressions, so you can load up a list of items into an object with the id as the key and cross reference from other items
Chris Reeves
@evs-chris
Nov 11 2017 17:55
unrelated, but if you notice words that are completely out of place in my responses, it's because the keyboard on my phone apparently uses mad libs for its machine learning
I use trace typing, and it helpfully matches characters that I don't even come close to touching most of the time