本文整理汇总了TypeScript中Immutable.List.shift方法的典型用法代码示例。如果您正苦于以下问题:TypeScript List.shift方法的具体用法?TypeScript List.shift怎么用?TypeScript List.shift使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.List
的用法示例。
在下文中一共展示了List.shift方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: reducer
//.........这里部分代码省略.........
mutableTrack.set('id', nextTrackId(timeline))
const oldTitle = track.getIn(['fields', 'title'])
mutableTrack.setIn(['fields', 'title'], oldTitle !== '' ? `${oldTitle} Copy` : '')
let annotationCounter = 0
mutableTrack.set('annotationStacks', mutableTrack.get('annotationStacks').map((stack: any) => {
return stack.map((annotation: any) => {
return annotation.set('id', nextAnnotationId(timeline)+(annotationCounter++))
})
}))
})
return state.updateIn(['meta', 'timeline', 'tracks'], tracks => {
return tracks.insert(trackIndex+1, duplicate)
})
}
case project.PROJECT_INSERTAT_TRACK: {
const {currentTrackIndex, insertAtIndex} = action.payload
const tracks = state.getIn(['meta', 'timeline', 'tracks'])
const swapped = tracks.withMutations((mTracks: any) => {
// mTracks ~ mutableTracks
const tmp = mTracks.get(currentTrackIndex)
mTracks.set(currentTrackIndex, mTracks.get(insertAtIndex))
mTracks.set(insertAtIndex, tmp)
})
return state.setIn(['meta', 'timeline', 'tracks'], swapped)
}
case project.PROJECT_PUSH_UNDO: {
const updatedRedo = state.setIn(['snapshots', 'redo'], List())
return updatedRedo.updateIn(['snapshots', 'undo'], (undoList: List<Record<ProjectSnapshot>>) => {
// Ensure max snapshot stack size
if(undoList.size < _SNAPSHOTS_MAX_STACKSIZE_) {
// Insert first
return undoList.unshift(action.payload)
} else {
// Remove last, insert first
return undoList.pop().unshift(action.payload)
}
})
}
case project.PROJECT_UNDO: {
const undoList: List<Record<ProjectSnapshot>> = state.getIn(['snapshots', 'undo'])
const redoList: List<Record<ProjectSnapshot>> = state.getIn(['snapshots', 'redo'])
if(undoList.size > 0) {
const undoSnapshot = undoList.first() as Record<ProjectSnapshot>
const currentSnapshot = new ProjectSnapshotRecordFactory({
timestamp: Date.now(),
state: state.get('meta', null)!
})
const updatedRedo = state.setIn(['snapshots', 'redo'], redoList.unshift(currentSnapshot))
const updatedUndo = updatedRedo.setIn(['snapshots', 'undo'], undoList.shift())
return updatedUndo.set('meta', undoSnapshot.get('state', null))
}
return state
}
case project.PROJECT_REDO: {
const undoList: List<Record<ProjectSnapshot>> = state.getIn(['snapshots', 'undo'])
const redoList: List<Record<ProjectSnapshot>> = state.getIn(['snapshots', 'redo'])
if(redoList.size > 0) {
const redoSnapshot = redoList.first() as Record<ProjectSnapshot>
const currentSnapshot = new ProjectSnapshotRecordFactory({
timestamp: Date.now(),
state: state.get('meta', null)!
})
const updatedUndo = state.setIn(['snapshots', 'undo'], undoList.unshift(currentSnapshot))
const updatedRedo = updatedUndo.setIn(['snapshots', 'redo'], redoList.shift())