These are chat archives for ractivejs/ractive

12th
Jul 2018
Cerem Cem ASLAN
@ceremcem
Jul 12 2018 18:30
question: how can I yield from ractive's ui update execution?
problem is that if I have a heavy ui update, ractive gets so busy that no other process can be run, thus there are lots of timeout issues taking place
Cerem Cem ASLAN
@ceremcem
Jul 12 2018 18:51
only workaround I can think of is that maybe I can explode an object and set-merge-set incrementally
kouts
@kouts
Jul 12 2018 18:59
Coincidence @ceremcem I'm trying to find an issue regarding UI performance too these days, I don't think is related to Ractive though
kouts
@kouts
Jul 12 2018 19:09
@ceremcem do you have the option of processing things and then send a map of keypaths - values to Ractive for a one-shot update (or set)?
Cerem Cem ASLAN
@ceremcem
Jul 12 2018 19:10
that's exactly what I'm currently doing
kouts
@kouts
Jul 12 2018 19:12
I image that it must be a pretty big update
Cerem Cem ASLAN
@ceremcem
Jul 12 2018 19:12
kind of, yes
Chris Reeves
@evs-chris
Jul 12 2018 19:40
unfortunately, there's not really a way to incrementally update beyond array push or maybe merge setting the object
that's going to be true of any massive dom manipulation though, even with plain js
the best path to responsive pages is to only render as much as is necessary at any given point
I've gotten really good at pagination :)
kouts
@kouts
Jul 12 2018 19:45
I'm working on a pagination right now
pretty simple stuff influenced by @dagnelies dataset
Joseph
@fskreuz
Jul 12 2018 20:16
This treads into the territory of async rendering, batching, fibers and stuff - something Ractive doesn't do.
It's a tradeoff between sync and async. Predictable synchronous operations at the cost of performance, or speedy async renders at the cost of grey-matter mashing. :grin:
Cerem Cem ASLAN
@ceremcem
Jul 12 2018 20:48
setting the keypath asynchronously (setTimeout(() => {this.set('mykeypath', myvaule)}, 100)) has solved the problem for now.
but I have to note that I think we need ractive.setAsync(..., callback) to perform non-freezing long operations
Joseph
@fskreuz
Jul 12 2018 20:56
Sounds like a feature request! Tag 'em and bag 'em! :grin:
I mean, if we're doing 1.0 soon, this would be a good 2.0 issue (or a 1.x issue).
Chris Reeves
@evs-chris
Jul 12 2018 21:33
what would that look like? Just an raf set?
kouts
@kouts
Jul 12 2018 21:34
General question - sorry to interrupt: I have monkeypatched a function from an external library using this method
var origUpdate = SomeClass.prototype.update;
SomeClass.prototype.update = function(){
    // Do some things here
    origUpdate.apply(this, arguments);
    // Do some things here
}
Chris Reeves
@evs-chris
Jul 12 2018 21:34
If so, it'd be super simple to throw an option to set to make it happen
kouts
@kouts
Jul 12 2018 21:35
now I want to debounce this update method, is there any way I could do that?
Chris Reeves
@evs-chris
Jul 12 2018 21:35
you have lodash available?
kouts
@kouts
Jul 12 2018 21:35
No but please suggest a solution as if I had
Chris Reeves
@evs-chris
Jul 12 2018 21:37
import debounce from lodash and just wrap the function with it e.g. = debounce(function() {...})
that's my go to
there's also a throttle in lodash
kouts
@kouts
Jul 12 2018 21:37
yes but which function?
Chris Reeves
@evs-chris
Jul 12 2018 21:37
the one you supply
sorry, on mobile or I'd edit your example
kouts
@kouts
Jul 12 2018 21:38
so like this?
var origUpdate = SomeClass.prototype.update;
SomeClass.prototype.update = function(){
    // Do some things here
    debounce(origUpdate.apply(this, arguments), 250);
    // Do some things here
}
Chris Reeves
@evs-chris
Jul 12 2018 21:39
no, starting on line 2, around your function
unless you only want to debounce the original and not yours, in which case wrap the someclass.proto.update with debounce
kouts
@kouts
Jul 12 2018 21:41
ok so like this
var origUpdate = SomeClass.prototype.update;
SomeClass.prototype.update = debounce(function(){
    // Do some things here
    origUpdate.apply(this, arguments);
    // Do some things here
}, 250);
Chris Reeves
@evs-chris
Jul 12 2018 21:41
yep
kouts
@kouts
Jul 12 2018 21:43
ok I'll try this thanks
kouts
@kouts
Jul 12 2018 22:02
I doesn't behave as I want to, what it does is that it delays the execution for eg 5 seconds so the method continues to fire but with a 5 second gap. What I want is to limit the execution to 1 time during these 5 seconds
Chris Reeves
@evs-chris
Jul 12 2018 22:03
swap debounce for throttle