goatslacker / alt

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

getState() doesn't return class instance. #552

Closed hiro1107 closed 8 years ago

hiro1107 commented 8 years ago

I try returning class instance through getState() but it always just return just Javascript Object. Is this default behavior? How to return class instance? Below is the example code.

import alt from '../alt';
import ScheduleActions from '../actions/ScheduleActions.js';
import ScheduleApiUtils from '../utils/ScheduleApiUtils';

class ScheduleStore {
  constructor() {
    this.state = {
      test: new String("test")
    }
    console.log(this.state.test instanceof String); // return true
  }
  static getSchedules() {
    console.log(this.getState().test instanceof String); // return false
  }
}
export default alt.createStore(ScheduleStore, 'ScheduleStore'); 
goatslacker commented 8 years ago

Override getState to that behavior

goatslacker commented 8 years ago

You'll want to create a getState method and pass it to exportPublicMethods