本文整理汇总了TypeScript中fluxx.LocalStore函数的典型用法代码示例。如果您正苦于以下问题:TypeScript LocalStore函数的具体用法?TypeScript LocalStore怎么用?TypeScript LocalStore使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LocalStore函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: LocalStore
export const loginStore = () => LocalStore(initialState, on => {
on(actions.updateEmail, (state, value) => {
return Object.assign({}, state, {
email: updateFieldValidation(state.email, value, validateEmail(value))
})
})
on(actions.updatePassword, (state, value) => {
return Object.assign({}, state, {
password: updateFieldValidation(state.password, value, validatePassword(value))
})
})
on(actions.updateErrors, (state, value) => {
return Object.assign({}, state, {errors: value})
})
on(actions.closeErrors, (state) => {
return Object.assign({}, state, {errors: null})
})
on(actions.success, (state) => {
return Object.assign({}, state, {step: "success"})
})
})
示例2: LocalStore
export const resetPasswordStore = () => LocalStore(initialState, on => {
on(actions.updatePassword, (state, value) => {
return Object.assign({}, state, {
password: updateFieldValidation(state.password, value, validatePassword(value)),
password2: updateUnchangedFieldValidation(state.password2, state.password2.value, validatePassword2(value, state.password2.value))
})
})
on(actions.updatePassword2, (state, value) => {
return Object.assign({}, state, {
password2: updateFieldValidation(state.password2, value, validatePassword2(state.password.value, value))
})
})
on(actions.updateErrors, (state, value) => {
return Object.assign({}, state, {errors: value})
})
on(actions.closeErrors, (state) => {
return Object.assign({}, state, {errors: null})
})
on(actions.success, (state) => {
return Object.assign({}, state, {step: "success"})
})
})
示例3: LocalStore
export const showListStore = () => LocalStore(initialState, on => {
on(actions.updateList, (state, shows) => {
return copy(state, {
nextShows: shows.filter(_ => _.plays && _.plays.length),
previousShows: shows.filter(_ => !(_.plays && _.plays.length))
})
})
})
示例4: LocalStore
export const playPageStore = () => LocalStore(initialState, on => {
on(actions.initialize, (state, {company, show, play, playsFromShow}) => {
return copy(state, {
company, show, play,
otherPlays: arrays.sort(playsFromShow.filter(p => p.id !== play.id), (p1, p2) => p1.date.getTime() - p2.date.getTime())
})
})
})
示例5: LocalStore
export const companyListStore = () => LocalStore(initialState, on => {
on(actions.updateList, (state, companies) => {
return copy(state, {
vepCompanies: arrays.sort(companies.filter(_ => _.isVep), compareCompanies),
notVepCompanies: arrays.sort(companies.filter(_ => !_.isVep), compareCompanies)
})
})
})
示例6: LocalStore
export const adhesionListStore = () => LocalStore(initialState, on => {
on(actions.initialize, (state, {period, adhesions}) => {
return copy(state, {
period: period,
acceptedAdhesions: adhesions.filter(_ => _.accepted),
notAcceptedAdhesions: adhesions.filter(_ => !_.accepted)
})
})
})
示例7: LocalStore
export const navigationStore = () => LocalStore(initialState, on => {
on(actions.initialize, (state, {shows, plays, pages}) => {
return copy(state, {shows, plays, pages})
})
on(actions.updateSession, (state, session) => {
return copy(state, {session})
})
})
示例8: LocalStore
export const requestAdhesionFormStore = () => LocalStore(initialState, on => {
on(actions.initialize, (state, {acceptedPeriods}) => {
return copy(state, {step: "form", acceptedPeriods})
})
on(actions.updatePeriod, (state, value) => {
return copy(state, {
period: updateFieldValidation(state.period, value, Valid(value))
})
})
on(actions.addMember, (state) => {
const newMembers = arrays.append(state.members.value, defaultMember)
return copy(state, {
members: updateFieldValidation(state.members, newMembers, validateMembers(newMembers))
})
})
on(actions.removeMember, (state, index) => {
const newMembers = arrays.remove(state.members.value, index)
return copy(state, {
members: updateFieldValidation(state.members, newMembers, validateMembers(newMembers))
})
})
on(actions.updateMemberFirstName, (state, {index, value}) =>
updateMember(state, index, member => copy(member, {
firstName: updateFieldValidation(member.firstName, value, validateNonBlank(value))
}))
)
on(actions.updateMemberLastName, (state, {index, value}) =>
updateMember(state, index, member => copy(member, {
lastName: updateFieldValidation(member.lastName, value, validateNonBlank(value))
}))
)
on(actions.updateMemberBirthday, (state, {index, value}) =>
updateMember(state, index, member => copy(member, {
birthday: updateFieldValidation(member.birthday, value, validatePassed(value))
}))
)
on(actions.updateMemberActivity, (state, {index, value}) =>
updateMember(state, index, member => copy(member, {
activity: updateFieldValidation(member.activity, value, Valid(value))
}))
)
on(actions.closeErrors, (state) => {
return copy(state, {errors: null})
})
on(actions.success, (state) => {
return copy(state, {step: "success"})
})
})
示例9: LocalStore
export const periodAdhesionListStore = () => LocalStore(initialState, on => {
on(actions.updateList, (state, periodsAdhesion) => {
return copy(state, {
currentPeriodsAdhesion: periodsAdhesion.filter(_ => isCurrent(_.period)),
futurePeriodsAdhesion: periodsAdhesion.filter(_ => isFuture(_.period)),
passedPeriodsAdhesion: periodsAdhesion.filter(_ => isPassed(_.period))
})
})
})
示例10: LocalStore
export const profilePageStore = () => LocalStore(initialState, on => {
on(actions.initialize, (state, {profile, adhesions}) => {
return copy(state, {
profile: profile,
acceptedAdhesions: adhesions.filter(_ => _.accepted),
notAcceptedAdhesions: adhesions.filter(_ => !_.accepted)
})
})
})