These are chat archives for ractivejs/ractive

20th
Jun 2018
kouts
@kouts
Jun 20 2018 09:45
I noticed today the use method, is there any example available on how to use use ? :smile:
Just a function
kouts
@kouts
Jun 20 2018 10:18
@PaulMaly_twitter what does it do?
Paul Maly
@PaulMaly_twitter
Jun 20 2018 10:18
Usage:
ractive.use(ready(options));
Doesn’t matter, it’s the only ractive plugin example I know))
But basically it adds few methods to Ractive for isomorphic things
kouts
@kouts
Jun 20 2018 10:20
so this adds methods to the prototype?
like e.g public methods?
Paul Maly
@PaulMaly_twitter
Jun 20 2018 10:24
Yep, it’s one of plugins use case
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 10:49
@kouts .hasAttribute() implementation: here
kouts
@kouts
Jun 20 2018 10:51
so @ceremcem you also use it as a public method right?
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 10:51
yes, like @.set(),
Paul Maly
@PaulMaly_twitter
Jun 20 2018 11:03
@kouts also you able to add functionality to current instance only or static proprieties to Ractive constructor itself
kouts
@kouts
Jun 20 2018 11:26
I think I get it
thanks
kouts
@kouts
Jun 20 2018 11:31
Paul Maly
@PaulMaly_twitter
Jun 20 2018 11:42
Hm, very complex question. There’s an example:
You make some async operations, e.g. data fetching, distributed on all components hierarchy. It’s difficult to get a point then all of this ops are finished.
Paul Maly
@PaulMaly_twitter
Jun 20 2018 11:50
With this plugin you able to do this:
// in any component
this.wait(promise);

// where you need to
this.ready((err, data) => {});
data will contain all results of all watings structured according to components hierarchy
kouts
@kouts
Jun 20 2018 12:03
nice!
Joseph
@fskreuz
Jun 20 2018 12:13
@kouts usefacilitates what is effectively what other libraries call "prototype patching" (although not limited to prototypes). You augment an existing constructor/prototype/instance instead of extending them - adding functionality on-the-fly/post-instantiation instead of extending or during init. The full discussion and explanatory examples can be found here ractivejs/ractive#3178
Paul Maly
@PaulMaly_twitter
Jun 20 2018 12:39
@kouts I usually use this plugin with SSR and isomorphic approach. So, on the server it would something like this (express middleware):
const run = require('../src/app');

module.exports = () => (req, res, next) => {

    const app = run();

    app.ready((error, data) => {

        const content = app.toHTML(),
            styles = app.toCSS();

        app.teardown();

        res.render('index', { content, styles, data, error });
    });
};
kouts
@kouts
Jun 20 2018 12:40
I see, haven't played with SSR yet but I think I get the use case.
Paul Maly
@PaulMaly_twitter
Jun 20 2018 12:41
This is full example of SSR, actually, except routing, I think.
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 14:04
by the way, Ractive is very handy while writing a reverse engineering tool.
Joseph
@fskreuz
Jun 20 2018 14:50
Oooh! What are you reverse-engineering? :grin:
Yep, Ractive is pretty good at quickly slapping together a UI for just about anything. Thanks in part to its no-dependencies, no-builds nature.
Chris Reeves
@evs-chris
Jun 20 2018 14:51
indeed, inquiring minds want to know
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 14:51
a propriatery accounting software's database, as a part of our client project
Chris Reeves
@evs-chris
Jun 20 2018 14:52
that's always a ball of laughs
is it decently designed?
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 14:53
absolutely not :D
I figured out that there are already 750 unused tables in it
Chris Reeves
@evs-chris
Jun 20 2018 14:54
that's... wow
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 14:54
column names are mess
Joseph
@fskreuz
Jun 20 2018 14:54
:joy:
Chris Reeves
@evs-chris
Jun 20 2018 14:55
decoy tables
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 14:55
yeah. they think so :smile:
Chris Reeves
@evs-chris
Jun 20 2018 14:55
what db?
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 14:55
mssql
Joseph
@fskreuz
Jun 20 2018 14:55
I remember requesting a DBA to delete/rename unused columns. Told me to just leave it there to avoid breaking stuff. 2 weeks later, it was repurposed to something else, but the name remained the same. :joy:
Chris Reeves
@evs-chris
Jun 20 2018 14:57
worst I've had is a vfp db from way back that had an 8 char limit on names for... reasons
at least it's not oracle?
question of the day: what's your go to db? I'm a postgres guy from way back
working on a project now with a shared ractive store that gets kept up to date live via websocket coordinated by redis and backed by postgres
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 15:03
I do prefer CouchDB with a custom middleware that communicates with the browser over Websockets (SocketIO) eventually.
the worst thing about CouchDB was a transactional operations (as it is designed as a distributed database, so it is eventually consistent) I implemented transaction mechanism on my own
Chris Reeves
@evs-chris
Jun 20 2018 15:04
that was my issue with mongo... I evaluated couch and really like it, but it hasn't really fit anywhere yet
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 15:05
mssql was my first database in my job carreer
Chris Reeves
@evs-chris
Jun 20 2018 15:05
most of the line of business apps I work with are very much relational
at least it wasn't access 😁
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 15:06
haha :D
the transaction is handled by this algorithm in my middleware
Chris Reeves
@evs-chris
Jun 20 2018 15:11
interesting... I suppose documents are versioned and immutable, so rollback is just a matter of saying which versions should be canonical?
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 16:44
documents are immutable per revision (if you touch a document, then it gets a new revision). that's correct. but the transaction has nothing to do with a single document, but it interests in multiple documents (or a view). for example, if you want to decide whether you should save a document or not according to a view result, and if your document would affect the view result, then you should "LOCK" the document insertation, decide, then "UNLOCK" it.
Cerem Cem ASLAN
@ceremcem
Jun 20 2018 17:45

suppose you created a banking system with CouchDB. you should insert a document per transaction, like so:

{
  type: 'transaction', 
  from: '@evs-chirs'
  to: '@ceremcem'
  dollars: 5
}

by the help of a proper map/reduce function (view), you can get cumulative transaction amount with a single request. Since document insertations are atomic, whole bank accounts are zero in total, at any time. You don't have to do anything to make this work.

if you want to insert this document _if @evs-chirs has 5 dollars or more in his account, then you have to introduce a locking mechanism on your own
that's what I did so far