goatslacker / alt

Isomorphic flux implementation
http://alt.js.org/
3.45k stars 322 forks source link

Issue with Immutable datatypes on recycle #545

Closed tquetano-r7 closed 8 years ago

tquetano-r7 commented 8 years ago

So I've noticed a strange issue where if I have a non-Immutable store, but I use Immutable datatypes in the constructor, when I recycle the store I get the plain JS version of the object.

goatslacker commented 8 years ago

Are you using the ImmutableUtil? Immutable Map?

tquetano-r7 commented 8 years ago

In this case I'm not using ImmutableUtil, but making constructor variables Immutable values. example:

class MyStore {
    constructor() {
        this.example = Immutable.Map({
            some:"value"
        });

        this.example2 = Immutable.fromJS([
            "arrays",
            "too"
        ]);
    }
    ...
}

And it's my understanding that ImmutableUtil is intended for when you want the entire Store to be one big Immutable object, not necessarily in a case like above. I know it's weird (and I'm now using ImmutableUtil on all new stores I create, that works perfectly), but I'm trying to avoid rewriting the entire store based on Immutable.

goatslacker commented 8 years ago

You'll have to provide your own hooks on how to bootstrap recycle and snapshot that since alt has no way of knowing what to do in that scenario.

Check out the lifecycle listeners.