-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EnabledNode PhET-iO API and support for LinkedElementIO in API va…
…lidation, mixin EnabledComponentAPIMixin into SliderAPI, #605
- Loading branch information
Showing
4 changed files
with
60 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2020, University of Colorado Boulder | ||
|
||
/** | ||
* PhET-iO API mixin EnabledComponent | ||
* | ||
* @author Michael Kauzmann (PhET Interactive Simulations) | ||
*/ | ||
|
||
import PropertyAPI from '../../axon/js/PropertyAPI.js'; | ||
import PropertyIO from '../../axon/js/PropertyIO.js'; | ||
import merge from '../../phet-core/js/merge.js'; | ||
import BooleanIO from '../../tandem/js/types/BooleanIO.js'; | ||
import sun from './sun.js'; | ||
|
||
const EnabledComponentAPIMixin = Type => { | ||
return class extends Type { | ||
|
||
/** | ||
* @param {Object} [options] | ||
*/ | ||
constructor( options ) { | ||
assert && assert( arguments.length === 0 || arguments.length === 1, '0 or 1 args expected' ); | ||
|
||
options = merge( { | ||
enabledPropertyOptions: { | ||
phetioFeatured: true, | ||
phetioType: PropertyIO( BooleanIO ) | ||
} | ||
}, options ); | ||
|
||
super( options ); | ||
|
||
this.enabledProperty = new PropertyAPI( options.enabledPropertyOptions ); | ||
} | ||
}; | ||
}; | ||
|
||
sun.register( 'EnabledComponentAPIMixin', EnabledComponentAPIMixin ); | ||
export default EnabledComponentAPIMixin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5b9a5f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/phetsims/phet-io/issues/1657