Skip to content

Commit

Permalink
[changed] enums to be string consts
Browse files Browse the repository at this point in the history
Summary:
It just feels more JavaScripty.  FWIW, I think enums are a feature the TS team now regrets - it goes against their general ethos of "pure JS + types".

Closes #155

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, featherless

Reviewed By: O2 Material Motion, #material_motion, featherless

Tags: #material_motion

Differential Revision: http://codereview.cc/D3126
  • Loading branch information
appsforartists committed May 2, 2017
1 parent 40f2cce commit 60cd82c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
16 changes: 8 additions & 8 deletions packages/core/src/GestureRecognitionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* under the License.
*/

export enum GestureRecognitionState {
POSSIBLE,
BEGAN,
CHANGED,
ENDED,
CANCELLED,
FAILED,
RECOGNIZED = ENDED,
export const GestureRecognitionState = {
POSSIBLE: 'possible',
BEGAN: 'began',
CHANGED: 'changed',
ENDED: 'ended',
RECOGNIZED: 'ended',
CANCELLED: 'cancelled',
FAILED: 'failed',
};

export default GestureRecognitionState;
8 changes: 4 additions & 4 deletions packages/core/src/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* under the License.
*/

export enum State {
AT_REST = 0,
ACTIVE = 1,
}
export const State = {
AT_REST: 'at_rest',
ACTIVE: 'active',
};
export default State;
2 changes: 0 additions & 2 deletions packages/core/src/ThresholdSide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* under the License.
*/

// Using const instead of enum because `'above'` is more meaningful in a log/to
// JS developers than `0`.
export const ThresholdSide = {
ABOVE: 'above',
WITHIN: 'within',
Expand Down
2 changes: 1 addition & 1 deletion packages/demos-react/src/QuickiePointerEventTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class QuickiePointerEventTest extends React.Component {
State
</td>
<td>
{ GestureRecognitionState[state] }
{ state }
</td>
</tr>
<tr>
Expand Down

0 comments on commit 60cd82c

Please sign in to comment.