Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access to singleton class method #12

Closed
bsr203 opened this issue Jun 13, 2015 · 1 comment
Closed

access to singleton class method #12

bsr203 opened this issue Jun 13, 2015 · 1 comment

Comments

@bsr203
Copy link

bsr203 commented Jun 13, 2015

Hello,

Is it possible to get access to methods of an exported class. In my case a singleton flux store, something like.

class TestStore extends Store {

  constructor() {
    super();

    this.state = {};
  }

  handleAction(action) {
    const {type, payload} = action;
    switch (type) {
      case 'TEST_ADD'
        ....
     }); 
  }

  getState(){
    return his.state;
  }
 }

export default TestStore.getInstance();

the super class method getInstance() returns a singleton instance.

now, is there a way get hold of handleAction in my test file. Something along the lines of

let handleAction = TestStore.__get__("handleAction");

when I tried I get error

  TypeError: undefined is not a constructor (evaluating '__$Getters__[name]()') in http://0.0.0.0:3000/bundle.js (line 197)

I could probably export these private method to a public variable, and remove on production build. But, wonder is it possible without that.

@bsr203
Copy link
Author

bsr203 commented Jun 13, 2015

closing this, as I can just call TestStore.handleAction() directly. I had the impression only things assigned to this explicitly in the constructor is considered public.

@bsr203 bsr203 closed this as completed Jun 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant