Skip to content

Commit

Permalink
Rename RichEnumerationIO ->EnumerationIO, delete old version, move fi…
Browse files Browse the repository at this point in the history
…le to tandem (with history), phetsims/phet-core#97
  • Loading branch information
zepumph committed Jan 13, 2022
1 parent a915fb0 commit aecb689
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion js/EventType.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import EnumerationDeprecated from '../../phet-core/js/EnumerationDeprecated.js';
import EnumerationIO from '../../phet-core/js/EnumerationIO.js';
import EnumerationIO from './types/EnumerationIO.js';
import TandemConstants from './TandemConstants.js';
import tandemNamespace from './tandemNamespace.js';

Expand Down
14 changes: 7 additions & 7 deletions js/RichEnumerationIO.ts → js/types/EnumerationIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* @author Michael Kauzmann (PhET Interactive Simulations)
*/

import EnumerationValue from '../../phet-core/js/EnumerationValue.js';
import IRichEnumeration, { RichEnumerationContainer } from '../../phet-core/js/IRichEnumeration.js';
import IOType from '../../tandem/js/types/IOType.js';
import StateSchema from '../../tandem/js/types/StateSchema.js';
import axon from './axon.js';
import EnumerationValue from '../../../phet-core/js/EnumerationValue.js';
import IRichEnumeration, { RichEnumerationContainer } from '../../../phet-core/js/IRichEnumeration.js';
import IOType from './IOType.js';
import StateSchema from './StateSchema.js';
import tandemNamespace from '../tandemNamespace.js';

// Cache each parameterized IOType so that it is only created once.
const cache = new Map<IRichEnumeration<any>, IOType>();
Expand All @@ -33,7 +33,7 @@ const EnumerationIO = <T extends EnumerationValue>( enumerationContainer: RichEn
documentation: `Possible values: ${keys.join( ', ' )}.${additionalDocs}`,
toStateObject: ( t: T ) => enumeration.getKey( t ),
fromStateObject: ( stateObject: string ): T => {
assert && assert( typeof stateObject === 'string', 'unsupported RichEnumerationIO value type, expected string' );
assert && assert( typeof stateObject === 'string', 'unsupported EnumerationIO value type, expected string' );
assert && assert( keys.includes( stateObject ), `Unrecognized value: ${stateObject}` );
return enumeration.getValue( stateObject )!;
},
Expand All @@ -46,5 +46,5 @@ const EnumerationIO = <T extends EnumerationValue>( enumerationContainer: RichEn
return cache.get( enumeration )!;
};

axon.register( 'EnumerationIO', EnumerationIO );
tandemNamespace.register( 'EnumerationIO', EnumerationIO );
export default EnumerationIO;

0 comments on commit aecb689

Please sign in to comment.