Skip to content

Commit

Permalink
fix valueType in IOTypes for Particle subclasses, #231
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed May 3, 2024
1 parent 33759fb commit 7c839b9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion js/common/model/HeavyParticle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class HeavyParticle extends Particle {
}

public static readonly HeavyParticleIO = new IOType<HeavyParticle, HeavyParticleStateObject>( 'HeavyParticleIO', {
valueType: Particle,
valueType: HeavyParticle,
stateSchema: Particle.STATE_SCHEMA,
fromStateObject: HeavyParticle.fromStateObject
} );
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/LightParticle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class LightParticle extends Particle {
}

public static readonly LightParticleIO = new IOType<LightParticle, LightParticleStateObject>( 'LightParticleIO', {
valueType: Particle,
valueType: LightParticle,
stateSchema: Particle.STATE_SCHEMA,
fromStateObject: LightParticle.fromStateObject
} );
Expand Down
8 changes: 5 additions & 3 deletions js/diffusion/model/DiffusionParticle1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type SelfOptions = EmptySelfOptions;
export type DiffusionParticle1Options = SelfOptions &
StrictOmit<DiffusionParticleOptions, 'colorProperty' | 'highlightColorProperty'>;

export type DiffusionParticle1StateObject = ParticleStateObject;

export default class DiffusionParticle1 extends DiffusionParticle {

public constructor( providedOptions?: DiffusionParticle1Options ) {
Expand All @@ -35,7 +37,7 @@ export default class DiffusionParticle1 extends DiffusionParticle {
/**
* Deserializes an instance of DiffusionParticle1.
*/
private static fromStateObject( stateObject: ParticleStateObject ): DiffusionParticle1 {
private static fromStateObject( stateObject: DiffusionParticle1StateObject ): DiffusionParticle1 {
return new DiffusionParticle1( {
x: stateObject.x,
y: stateObject.y,
Expand All @@ -46,8 +48,8 @@ export default class DiffusionParticle1 extends DiffusionParticle {
} );
}

public static readonly DiffusionParticle1IO = new IOType<DiffusionParticle1, ParticleStateObject>( 'DiffusionParticle1IO', {
valueType: Particle,
public static readonly DiffusionParticle1IO = new IOType<DiffusionParticle1, DiffusionParticle1StateObject>( 'DiffusionParticle1IO', {
valueType: DiffusionParticle1,
stateSchema: Particle.STATE_SCHEMA,
fromStateObject: DiffusionParticle1.fromStateObject
} );
Expand Down
8 changes: 5 additions & 3 deletions js/diffusion/model/DiffusionParticle2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type SelfOptions = EmptySelfOptions;
export type DiffusionParticle2Options = SelfOptions &
StrictOmit<DiffusionParticleOptions, 'colorProperty' | 'highlightColorProperty'>;

export type DiffusionParticle2StateObject = ParticleStateObject;

export default class DiffusionParticle2 extends DiffusionParticle {

public constructor( providedOptions?: DiffusionParticle2Options ) {
Expand All @@ -35,7 +37,7 @@ export default class DiffusionParticle2 extends DiffusionParticle {
/**
* Deserializes an instance of DiffusionParticle1.
*/
private static fromStateObject( stateObject: ParticleStateObject ): DiffusionParticle2 {
private static fromStateObject( stateObject: DiffusionParticle2StateObject ): DiffusionParticle2 {
return new DiffusionParticle2( {
x: stateObject.x,
y: stateObject.y,
Expand All @@ -46,8 +48,8 @@ export default class DiffusionParticle2 extends DiffusionParticle {
} );
}

public static readonly DiffusionParticle2IO = new IOType<DiffusionParticle2, ParticleStateObject>( 'DiffusionParticle2IO', {
valueType: Particle,
public static readonly DiffusionParticle2IO = new IOType<DiffusionParticle2, DiffusionParticle2StateObject>( 'DiffusionParticle2IO', {
valueType: DiffusionParticle2,
stateSchema: Particle.STATE_SCHEMA,
fromStateObject: DiffusionParticle2.fromStateObject
} );
Expand Down

0 comments on commit 7c839b9

Please sign in to comment.