本文整理匯總了TypeScript中@dojo/framework/widget-core/Container.Container函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript Container函數的具體用法?TypeScript Container怎麽用?TypeScript Container使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Container函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getProperties
addTodo,
todoInput,
removeTodo,
toggleTodo,
toggleTodos,
clearCompleted,
editTodo,
saveTodo
} from './../actions/todoActions';
function getProperties({ store }: ReduxInjectorPayload<any, any>) {
const state = store.getState();
return {
addTodo: () => store.dispatch(addTodo()),
todoInput: (todo: string) => store.dispatch(todoInput(todo)),
removeTodo: (id: string) => store.dispatch(removeTodo(id)),
toggleTodo: (id: string) => store.dispatch(toggleTodo(id)),
toggleTodos: () => store.dispatch(toggleTodos()),
clearCompleted: () => store.dispatch(clearCompleted()),
editTodo: (id: string) => store.dispatch(editTodo(id)),
saveTodo: (id: string, label?: string) => store.dispatch(saveTodo(id, label)),
currentTodo: state.currentTodo,
completedCount: state.completedCount,
activeCount: state.activeCount,
todos: state.todos
};
}
export const TodoAppContainer = Container(TodoApp, 'application-state', { getProperties });
示例2: getProperties
import { Container } from '@dojo/framework/widget-core/Container';
import { Context } from './../Context';
import { App } from './../widgets/App';
function getProperties(context: Context, properties: any): any {
return {
route: context.route
};
}
export const AppContainer = Container(App, 'state', { getProperties });
示例3: getProperties
import { Container } from '@dojo/framework/widget-core/Container';
import { Context } from './../Context';
import { Comments, CommentsProperties } from './../widgets/Comments';
function getProperties(context: Context, properties: CommentsProperties): CommentsProperties {
const { id } = properties;
return {
item: context.item,
id
};
}
export const CommentsContainer = Container(Comments, 'state', { getProperties });
示例4: getProperties
import { Container } from '@dojo/framework/widget-core/Container';
import { Context } from './../Context';
import { Menu, MenuProperties } from './../widgets/Menu';
function getProperties(context: Context, properties: MenuProperties): MenuProperties {
return {
currentCategory: context.category
};
}
export const MenuContainer = Container(Menu, 'state', { getProperties });