These are chat archives for canjs/canjs

11th
Dec 2018
Viktor Busko
@Lighttree
Dec 11 2018 07:42
Hi Guys, in cases when I have some list, and I need to do something with DOM as soon as this list changes.
I put such logic in events section in Component, because there is nice way to track list changes.
But I have to wrap logic to setTimeout in case I need to work with updated DOM, because as this event happens, DOM still old one.
Is there any way to avoid this or better way to do this ?
import Component from 'can-component/can-component';
import DefineMap from 'can-define/map/map';

export const ViewModel = DefineMap.extend({
    renderedList: {
        Type: [Item],
        get() {
            return /* some logic */;
        }
    },
});

export default Component.extend({
    tag: 'dynamic-list',
    ViewModel,
    view,
    events: {
        // SIDE EFFECTS
       '{viewModel} renderedList': function () {
            setTimeout(() => {
               /* do something with updated DOM */
            }, 0)
        }
    }
});
Kevin Phillips
@phillipskevin
Dec 11 2018 15:28
if you use listenTo in the connectedCallback, you can control what queue your callback runs in
but it defaults to the mutate queue, so I guess this might not help
can you trigger the side-effect another way?
I would probably use a canViewCallbacks.attr on the DOM that gets rendered
so the DOM itself triggers the side effect
Frank Lemanschik
@frank-dspeed
Dec 11 2018 16:11
oh again a missing pice of documentation :)
that i don't was aware of till now
thanks @phillipskevin
can you maybe also spend some light about https://github.com/tc39/proposal-observable
is any canjs observable compatible to that interface (api)
Kefir is
but is there any internal one?
only the observable api i don't talk about .of method and the other methods like filter
Matthew Phillips
@matthewp
Dec 11 2018 16:15
that proposal is dead
Frank Lemanschik
@frank-dspeed
Dec 11 2018 16:16
@Lighttree i use personal always the on inserted event to tigger such effects
@matthewp nope its not
for EMCA its current
ECMA
sorry i always mix the chars
i know that this was dead for CJS but as far as i am informed and i work with a lot of FRP coders
its current and used we all agree with that interface
Matthew Phillips
@matthewp
Dec 11 2018 16:19
It might be currently but it's been in stage 1 for like 5 years now with no progress. It's not going to happen
Frank Lemanschik
@frank-dspeed
Dec 11 2018 16:20
it happens at present all over
Matthew Phillips
@matthewp
Dec 11 2018 16:20
Notice no one is really working on it now.
Frank Lemanschik
@frank-dspeed
Dec 11 2018 16:20
thats not really true we work at present on something new
with time line based observables
and schedulers
but we want to keep that api with subscribe and next
every current streaming lib and even canjs is using a similar interface but not exactly this
the most big streaming libs are using it at present
but its ok the way it is the current canjs resolver-observable is easy to adopt
as we simply need in the last stream to call resolve
and we can append to that stream via stream.combine(oldValueProducingStream)
Frank Lemanschik
@frank-dspeed
Dec 11 2018 16:27
@matthewp here if your interested in the most current about that https://github.com/mostjs/core
this has not much to do with the main most package at present
it will get the core of the most package version 2.0
little livebinding example
and here some old examples with the old mostjs way for a complet framework
with routing and all that all based on streams the proposal is simply not moving because there is work in progress
but i would love when canjs would adopt the api now so i can simply suggest to all people to use canjs to be future save :)
i try to prepare a CanJS Straming viewModel the hackisch way at present till friday for a Proposal so you can jump into that :)
Frank Lemanschik
@frank-dspeed
Dec 11 2018 16:35
and CanJS is proud about Observables its the center of the Tech Page :)
so we have all the same interrests i think