Skip to content

Commit

Permalink
Merge pull request alibaba#113 from hyjfine/fix_misSpelling
Browse files Browse the repository at this point in the history
Correct spelling
  • Loading branch information
zjuwjf committed Mar 24, 2019
2 parents a955dd9 + 24f435c commit 50ce9a9
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion example/lib/todo_edit_page/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TodoEditPage extends Page<TodoEditState, ToDoState> {
effect: buildEffect(),
reducer: buildReducer(),
view: buildView,
middlewares: <Middleware<TodoEditState>>[
middleware: <Middleware<TodoEditState>>[
logMiddleware(tag: 'TodoEditPage'),
],
);
Expand Down
2 changes: 1 addition & 1 deletion example/lib/todo_list_page/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ToDoListPage extends Page<PageState, Map<String, dynamic>> {
slots: <String, Dependent<PageState>>{
'report': ReportConnector() + ReportComponent()
}),
middlewares: <Middleware<PageState>>[
middleware: <Middleware<PageState>>[
logMiddleware(tag: 'ToDoListPage'),
],
);
Expand Down
10 changes: 5 additions & 5 deletions lib/src/redux/apply_middleware.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'basic.dart';

/// Accumulate a list of Middleware that enhances Disptach to the Store.
/// Accumulate a list of Middleware that enhances Dispatch to the Store.
/// The wrapped direction of the Store.dispatch is from inside to outside.
StoreEnhancer<T> applyMiddleware<T>(List<Middleware<T>> middlewares) {
if (middlewares == null || middlewares.isEmpty) {
StoreEnhancer<T> applyMiddleware<T>(List<Middleware<T>> middleware) {
if (middleware == null || middleware.isEmpty) {
return null;
} else {
return (StoreCreator<T> creator) => (T initState, Reducer<T> reducer) {
assert(middlewares != null && middlewares.isNotEmpty);
assert(middleware != null && middleware.isNotEmpty);

final Store<T> store = creator(initState, reducer);
final Dispatch initialValue = store.dispatch;
Expand All @@ -16,7 +16,7 @@ StoreEnhancer<T> applyMiddleware<T>(List<Middleware<T>> middlewares) {
'Dispatching while constructing your middleware is not allowed. '
'Other middleware would not be applied to this dispatch.');
};
store.dispatch = middlewares
store.dispatch = middleware
.map((Middleware<T> middleware) => middleware(
dispatch: (Action action) => store.dispatch(action),
getState: store.getState,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/redux/basic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ typedef ReplaceReducer<T> = void Function(Reducer<T> reducer);
typedef Observable<T> = Stream<T> Function();

/// Definition of synthesizable functions.
typedef Composeable<T> = T Function(T next);
typedef Composable<T> = T Function(T next);

/// Definition of the function type that returns type R.
typedef Get<R> = R Function();

/// Definition of the standard Middleware.
typedef Middleware<T> = Composeable<Dispatch> Function({
typedef Middleware<T> = Composable<Dispatch> Function({
Dispatch dispatch,
Get<T> getState,
});
Expand Down
2 changes: 1 addition & 1 deletion lib/src/redux_adapter/dynamic_flow_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class _ItemBean implements ItemBean {
_ItemBean clone() => _ItemBean(type, data);
}

/// template is a map, drived by array
/// template is a map, driven by array
class DynamicFlowAdapter<T> extends Logic<T>
with RecycleContextMixin<T>
implements AbstractAdapter<T> {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/redux_adapter/recycle_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '../redux_component/redux_component.dart';
class RecycleContext<T> extends DefaultContext<T> {
final Map<Object, List<ContextSys<Object>>> _cachedMap =
<Object, List<ContextSys<Object>>>{};
final Map<Object, int> _usedIndextMap = <Object, int>{};
final Map<Object, int> _usedIndexMap = <Object, int>{};

RecycleContext({
AbstractLogic<T> factors,
Expand All @@ -33,11 +33,11 @@ class RecycleContext<T> extends DefaultContext<T> {
}

void markAllUnused() {
_usedIndextMap.clear();
_usedIndexMap.clear();
}

ContextSys<Object> reuseOrCreate(Object key, Get<ContextSys<Object>> create) {
final int length = _usedIndextMap[key] = (_usedIndextMap[key] ?? 0) + 1;
final int length = _usedIndexMap[key] = (_usedIndexMap[key] ?? 0) + 1;
final List<ContextSys<Object>> list =
_cachedMap[key] ??= <ContextSys<Object>>[];

Expand All @@ -54,7 +54,7 @@ class RecycleContext<T> extends DefaultContext<T> {

void cleanUnused() {
_cachedMap.removeWhere((Object key, List<ContextSys<Object>> value) {
final int usedCount = _usedIndextMap[key] ?? 0;
final int usedCount = _usedIndexMap[key] ?? 0;

for (int i = usedCount; i < value.length; i++) {
value[i].onLifecycle(LifecycleCreator.dispose());
Expand Down
4 changes: 2 additions & 2 deletions lib/src/redux_adapter/static_flow_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import '../redux_component/redux_component.dart';
import '../utils/utils.dart';
import 'recycle_context.dart';

/// template is an array, drived by maplike
/// template is an array, driven by map like
class StaticFlowAdapter<T> extends Logic<T>
with RecycleContextMixin<T>
implements AbstractAdapter<T> {
Expand Down Expand Up @@ -54,7 +54,7 @@ class StaticFlowAdapter<T> extends Logic<T>
final Dependent<T> dependent = _slots[i];
final Object subObject = dependent.subGetter(ctx.getState)();
if (!dependent.isComponent()) {
/// pred is subObject != null
/// precondition is subObject != null
if (subObject != null) {
/// use index of key
final ContextSys<Object> subCtx = ctx.reuseOrCreate(i, () {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/redux_component/auto_dispose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class _Fields {
class AutoDispose {
final _Fields _fields = _Fields();

void visit(void Function(AutoDispose) visiter) =>
_fields.children?.forEach(visiter);
void visit(void Function(AutoDispose) visitor) =>
_fields.children?.forEach(visitor);

bool get isDisposed => _fields.isDisposed;

Expand Down
14 changes: 7 additions & 7 deletions lib/src/redux_component/basic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ abstract class ViewUpdater<T> {
}

/// A little different with Dispatch (with if it is interrupted).
/// bool for sync-functions , interrupted if true
/// Futur<void> for async-functions ,should always be interrupted,
/// bool for sync-functions, interrupted if true
/// Futur<void> for async-functions, should always be interrupted.
typedef OnAction = dynamic Function(Action action);

/// Predicate if a component should be updated when the store is changed.
typedef ShouldUpdate<T> = bool Function(T old, T now);

/// Interrupt if not null not false
/// bool for sync-functions , interrupted if true
/// Futur<void> for async-functions ,should always be interrupted,
/// bool for sync-functions, interrupted if true
/// Futur<void> for async-functions, should always be interrupted.
typedef Effect<T> = dynamic Function(Action action, Context<T> ctx);

/// Because Effect<T> is an aysnc-function, if it has some self-state, we should use HigherEffect<T>
Expand All @@ -72,10 +72,10 @@ abstract class PageStore<T> extends Store<T> implements Broadcast {}

/// Seen in view-part or adapter-part
abstract class ViewService {
/// The way to build adapter which is configed in Dependencies.adapter
/// The way to build adapter which is configured in Dependencies.adapter
ListAdapter buildAdapter();

/// The way to build slot component which is configed in Dependencies.slots
/// The way to build slot component which is configured in Dependencies.slots
Widget buildComponent(String name);

/// Get BuildContext from the host-widget
Expand Down Expand Up @@ -121,7 +121,7 @@ abstract class Context<T> extends AutoDispose {
/// Get|Set extra data in context if needed.
Map<String, Object> get extra;

/// The way to build slot component which is configed in Dependencies.slots
/// The way to build slot component which is configured in Dependencies.slots
/// such as custom mask or dialog
Widget buildComponent(String name);

Expand Down
12 changes: 6 additions & 6 deletions lib/src/redux_component/component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,12 @@ typedef InitState<T extends Cloneable<T>, P> = T Function(P params);

@immutable
abstract class Page<T extends Cloneable<T>, P> extends Component<T> {
final List<Middleware<T>> middlewares;
final List<Middleware<T>> middleware;
final InitState<T, P> initState;

Page({
@required this.initState,
this.middlewares,
this.middleware,
@required ViewBuilder<T> view,
Reducer<T> reducer,
ReducerFilter<T> filter,
Expand All @@ -303,9 +303,9 @@ abstract class Page<T extends Cloneable<T>, P> extends Component<T> {
);

/// Expansion capability
List<Middleware<T>> buildMiddlewares(List<Middleware<T>> middlewares) {
List<Middleware<T>> buildMiddleware(List<Middleware<T>> middleware) {
return Collections.merge<Middleware<T>>(
<Middleware<T>>[interrupt$<T>()], middlewares);
<Middleware<T>>[interrupt$<T>()], middleware);
}

Widget buildPage(P param) {
Expand All @@ -314,7 +314,7 @@ abstract class Page<T extends Cloneable<T>, P> extends Component<T> {
storeBuilder: () => createPageStore<T>(
initState(param),
reducer,
applyMiddleware<T>(buildMiddlewares(middlewares)),
applyMiddleware<T>(buildMiddleware(middleware)),
),
));
}
Expand All @@ -323,7 +323,7 @@ abstract class Page<T extends Cloneable<T>, P> extends Component<T> {
return ({Dispatch dispatch, Get<T> getState}) {
return (Dispatch next) {
return (Action action) {
if (!shouldBeInterrupttedBeforeReducer(action)) {
if (!shouldBeInterruptedBeforeReducer(action)) {
next(action);
}
};
Expand Down
6 changes: 3 additions & 3 deletions lib/src/redux_component/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ class DefaultContext<T> extends ContextSys<T> with _ExtraMixin {
}
}

class _TwinceContext<T> extends ContextSys<T> with _ExtraMixin {
class _TwinContext<T> extends ContextSys<T> with _ExtraMixin {
final ContextSys<T> mainCtx;
final ContextSys<T> sidecarCtx;

_TwinceContext(this.mainCtx, this.sidecarCtx)
_TwinContext(this.mainCtx, this.sidecarCtx)
: assert(mainCtx != null && sidecarCtx != null) {
mainCtx.setParent(this);
sidecarCtx.setParent(this);
Expand Down Expand Up @@ -163,5 +163,5 @@ class _TwinceContext<T> extends ContextSys<T> with _ExtraMixin {
}

ContextSys<T> mergeContext<T>(ContextSys<T> mainCtx, ContextSys<T> sidecarCtx) {
return sidecarCtx != null ? _TwinceContext<T>(mainCtx, sidecarCtx) : mainCtx;
return sidecarCtx != null ? _TwinContext<T>(mainCtx, sidecarCtx) : mainCtx;
}
4 changes: 2 additions & 2 deletions lib/src/redux_component/debug_or_report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class $DebugOrReportCreator {
}
}

/// action-type which starts with '$' should be interruptted,
/// action-type which starts with '$' should be interrupted,
/// like $DebugOrReport
bool shouldBeInterrupttedBeforeReducer(Action action) {
bool shouldBeInterruptedBeforeReducer(Action action) {
final Object actionType = action.type;
return actionType != null && actionType.toString().startsWith('\$');
}
2 changes: 1 addition & 1 deletion lib/src/redux_component/logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Logic<T> implements AbstractLogic<T> {
return;
}

if (!shouldBeInterrupttedBeforeReducer(action)) {
if (!shouldBeInterruptedBeforeReducer(action)) {
ctx.pageBroadcast(action);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/src/utils/common_aop/performance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:async';
import '../aop.dart';
import '../debug.dart';

int _microsecsSinceEpoch() => DateTime.now().microsecondsSinceEpoch;
int _microSecsSinceEpoch() => DateTime.now().microsecondsSinceEpoch;

ApplyLikeEnhancer performanceAOP(String tag) {
return isDebug()
Expand All @@ -15,11 +15,11 @@ ApplyLikeEnhancer performanceAOP(String tag) {
if (result is Future) {
result.then((Object r) {
print(
'$tag performance <Future>: ${_microsecsSinceEpoch() - marked}');
'$tag performance <Future>: ${_microSecsSinceEpoch() - marked}');
return r;
});
} else {
print('$tag performance: ${_microsecsSinceEpoch() - marked}');
print('$tag performance: ${_microSecsSinceEpoch() - marked}');
}
return result;
};
Expand Down
4 changes: 2 additions & 2 deletions lib/src/utils/common_aop/throttle.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import '../aop.dart';

int _microsecsSinceEpoch() => DateTime.now().microsecondsSinceEpoch;
int _microSecsSinceEpoch() => DateTime.now().microsecondsSinceEpoch;

ApplyLikeEnhancer throttle(int millis) {
return (dynamic Function(List<dynamic>) functor) {
int last = 0;
return (List<dynamic> positionalArguments,
[Map<Symbol, dynamic> namedArguments]) {
final int now = _microsecsSinceEpoch();
final int now = _microSecsSinceEpoch();
final int elapsed = now - last;
if (elapsed >= millis) {
last = now;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/debug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ bool _debugFlag = false;
bool isDebug() {
assert(() {
_debugFlag = true;
return true;
return _debugFlag;
}());
return _debugFlag;
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_widgets/lib/page/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ bool toDoListErrorHandler(Exception exception, Context<ToDoList> ctx) {
return false;
}

Composeable<Dispatch> toDoListMiddleware({
Composable<Dispatch> toDoListMiddleware({
Dispatch dispatch,
Get<ToDoList> getState,
}) =>
Expand Down
2 changes: 1 addition & 1 deletion test/test_widgets/lib/test_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TestPage<T extends Cloneable<T>, P> extends Page<T, P> {
Key Function(T) key,
}) : super(
initState: initState,
middlewares: middlewares,
middleware: middlewares,
view: view,
reducer: reducer,
filter: filter,
Expand Down

0 comments on commit 50ce9a9

Please sign in to comment.