How to Extend Stores and Actions to another stores and actions
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 312
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I have a Standard Store and Standard Action.
I would like to use write another store that will extend the Standard Store, and another actions to extend the standard Actions.
How should I go about doing this?
Example:
``` js
/* standard store */
import Alt from '../../../altControl.js';
import {createStore, bind} from 'alt/utils/decorators';
import ActDummy from '../actions/actDummy.js';
@createStore(Alt)
class StoDummyStd {
constructor(props){
}
name = 'awesome';
@bind(ActDummy.updateName)
updateName(name) {
this.name = name;
}
}
export default StoDummyStd;
/* new store that need to extend standard store*/
import Alt from '../../../altControl.js';
import {createStore, bind} from 'alt/utils/decorators';
import ActDummy from '../actions/actDummy.js';
import StoDummyStd from './stoDummyStd.js';
@createStore(Alt)
class StoDummy extends StoDummyStd{
constructor(props){
super(props);
}
@bind(ActDummy.updateName)
updateName(name) {
this.name = name;
this.nick = 'nick'
}
}
export default StoDummy;
```
It just can't work like this.
```
throw new TypeError("Super expression must either be null or a function, n
^
TypeError: Super expression must either be null or a function, not object
```
Contributor guide
Research direction
Start by reproducing the inheritance example using altControl.js, alt/utils/decorators, StoDummyStd, and StoDummy, then inspect how the store and action decorators handle inherited classes. Check whether the reported TypeError is reproducible and identify the supported extension behavior; done should be a documented answer or a focused, tested change if inheritance is intended to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100