These are chat archives for canjs/canjs

22nd
Apr 2018
Dovid Bleier
@dbleier
Apr 22 2018 20:09
Hello All, I have been working upgrading a legacy can-map to a DefineMap but having some issues with dynamic property assignment
    addEmptyPlaylistSlideIfPlaylistIsEmpty(presentation) {
        this.trace('in sign.addEmptyPlaylistSlideIfPlaylistIsEmpty');
        if (this.isArrayEmpty(presentation.slideshows)) {
            presentation.assignDeep({ slideshows: [{ slides: [] }] });
        }

        if (this.isArrayEmpty(presentation.slideshows[0].slides)) {
            presentation.slideshows[0].assignDeep({ slides: [config.get('env').emptyPlaylistSlide] });
        }

        return presentation;
    },
presentation is a DefineMap
the line presentation.assignDeep({ slideshows: [{ slides: [] }] }); works
but when I then try resentation.slideshows[0].assignDeep({ slides: [config.get('env').emptyPlaylistSlide] }); it thinks slideshows[0] is a POJO, which means no assignDeep method
I thought assignDeep would propagate to all the children maps and lists
similarly, if I have a POJO presentation and but it in a DefineMap constructor, such as let p = new DefineMap(presentation) will it define-map the whole object or just the top layer?
I want to be able to serialize() the DefineMap and get all my props
when I simply tried presentation.slideshows = ... and then serialized, I got an empty object