Skip to content

Commit

Permalink
Parameterize Expando
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronlademann-wf committed Nov 1, 2016
1 parent dd869c5 commit c8b41b7
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/src/component_declaration/component_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,15 @@ abstract class UiComponent<TProps extends UiProps> extends react.Component {
// BEGIN Typed props helpers
//

/// Keep this Expando unparameterized to work around this bug: <https://github.com/dart-lang/sdk/issues/26743>
Expando _typedPropsCache = new Expando();
var _typedPropsCache = new Expando<TProps>();

/// A typed props object corresponding to the current untyped props Map ([unwrappedProps]).
///
/// Created using [typedPropsFactory] and cached for each Map instance.
@override
TProps get props {
var unwrappedProps = this.unwrappedProps;
/// Have to cast as [TProps] until we can parameterize [_typedPropsCache].
///
/// See: <https://github.com/dart-lang/sdk/issues/26743>
var typedProps = _typedPropsCache[unwrappedProps] as TProps; // ignore: avoid_as
var typedProps = _typedPropsCache[unwrappedProps];
if (typedProps == null) {
typedProps = typedPropsFactory(unwrappedProps);
_typedPropsCache[unwrappedProps] = typedProps;
Expand Down Expand Up @@ -211,19 +207,15 @@ abstract class UiStatefulComponent<TProps extends UiProps, TState extends UiStat
// BEGIN Typed state helpers
//

/// Keep this Expando unparameterized to work around this bug: <https://github.com/dart-lang/sdk/issues/26743>
Expando _typedStateCache = new Expando();
var _typedStateCache = new Expando<TState>();

/// A typed state object corresponding to the current untyped state Map ([unwrappedState]).
///
/// Created using [typedStateFactory] and cached for each Map instance.
@override
TState get state {
var unwrappedState = this.unwrappedState;
/// Have to cast as [TState] until we can parameterize [_typedStateCache].
///
/// See: <https://github.com/dart-lang/sdk/issues/26743>
var typedState = _typedStateCache[unwrappedState] as TState; // ignore: avoid_as
var typedState = _typedStateCache[unwrappedState];
if (typedState == null) {
typedState = typedStateFactory(unwrappedState);
_typedStateCache[unwrappedState] = typedState;
Expand Down

0 comments on commit c8b41b7

Please sign in to comment.