You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Strange behavior when actions classes extends an reusable abstract class #484
When class A and class C extends B, we expect output in console.log(this.constructor.name) in B class it's always 'A' (if we call a.method()) and 'C' if we call c.method.
Actual Behaviour:
if i call c.method(), it prints "A" (if a and c extends b).
Stack Trace/Error Message:
not necessary
Code
abstract class B{
public abstract getName();
@dispatch()
public doAction(){
console.log(this.getName(), this.constructor.name);
}
}
class AAction extends B{
public getName(){
return 'FOO';
}
}
class CAction extends B{
public getName(){
return 'Bar';
}
}
var a = new AAction();
var b = new BAction();
a.doAction(); //it prints correctly "FOO", 'AAction'
b.doAction(); //it prints wrongly "FOO", 'AAction', the correct is "Bar", "BAction"
it only occurs in store folder. It not occurs in others folder..
Activity
[#484] Investigate behavior when classes extend an abstract class
e-schultz commentedon Nov 17, 2017
@tigredonorte looking into this, and was trying to setup a unit test to reproduce the issue - https://github.com/angular-redux/store/pull/487/files
I tried a few combinations:
Unless I'm misunderstanding the test case - I was unable to reproduce what you are seeing. Is there any more details that you could provide?
I tend to avoid inheritance in my code so haven't run into this yet, but want to ensure I can meet your use cases also.