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

ActionsClass usage #501

Closed
yepitschunked opened this issue Oct 1, 2015 · 5 comments
Closed

ActionsClass usage #501

yepitschunked opened this issue Oct 1, 2015 · 5 comments

Comments

@yepitschunked
Copy link

I have some information in my stores, that my actions need to pass when creating an API client object. I'm using alt instances, so the API constructor has no access to these stores - I have to pass the data in Intuitively, I'd do something like this:

class MyAction {
  constructor() {
    this.apiClient = new ApiClient(this.alt.stores.AuthStore.getStuff());
  }

  makeRequest(params) {
    this.dispatch(params)
    this.apiClient.get('/endpoint', params)
  }
}

Unfortunately, this doesn't work, because the way Alt creates actions rips all the methods off of this class and binds them to an AltAction instead. Do you have any suggestions on alternatives, or maybe how we could improve how makeActions works with a class? As it stands, the classes don't behave like classes at all, and might as well be object hashes.

@goatslacker
Copy link
Owner

As it stands, the classes don't behave like classes at all, and might as well be object hashes.

+1

let me think about this.

@goatslacker
Copy link
Owner

ok there are two options here.

remove this.dispatch from alt or remove action classes altogether.

@taion
Copy link
Collaborator

taion commented Oct 2, 2015

Hey! I made the exact same complaint here: #359 :D

I had a few proposals there toward the end of the thread, all of which would have been major breaking API changes, but probably getting rid of action classes would be the simplest approach by far.

@goatslacker
Copy link
Owner

#503 removes this.dispatch from alt.

@goatslacker
Copy link
Owner

Will be releasing this at some point soon.

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

3 participants