本文整理汇总了TypeScript中Immutable.Set.has方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Set.has方法的具体用法?TypeScript Set.has怎么用?TypeScript Set.has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.Set
的用法示例。
在下文中一共展示了Set.has方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: reducer
//.........这里部分代码省略.........
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())
return updatedRedo.set('meta', redoSnapshot.get('state', null))
}
return state
}
case project.PROJECT_SELECT_ANNOTATION: {
const {type, selection} = action.payload
switch(type) {
case project.AnnotationSelectionType.Default: {
return state.withMutations(mState => {
mState.setIn(['selection', 'annotation', 'range'], Set())
mState.setIn(['selection', 'annotation', 'pick'], Set())
mState.setIn(['selection', 'annotation', 'selected'], selection)
})
}
case project.AnnotationSelectionType.Pick: {
const track = selection.get('track', null)!
const filterByTrackFunc = (sel: Record<AnnotationSelection>) => {
return sel.getIn(['track', 'id']) === track.get('id', null)
}
const rangeSelections: Set<Record<AnnotationSelection>> =
state.getIn(['selection', 'annotation', 'range']).filter(filterByTrackFunc)
const pickSelections: Set<Record<AnnotationSelection>> =
state.getIn(['selection', 'annotation', 'pick']).filter(filterByTrackFunc)
const peekSelected: Record<AnnotationSelection>|null = state.getIn(['selection', 'annotation', 'selected'])
const isAlreadyPicked = rangeSelections.has(selection) || pickSelections.has(selection)
return state.withMutations(mState => {
if(isAlreadyPicked) {
mState.setIn(['selection', 'annotation', 'range'], rangeSelections.delete(selection))
mState.setIn(['selection', 'annotation', 'pick'], pickSelections.delete(selection))
if(peekSelected && peekSelected.getIn(['annotation', 'id']) === selection.getIn(['annotation', 'id'])) {
mState.setIn(['selection', 'annotation', 'selected'], null)
}
} else {
// Set range, might be different due to filter
mState.setIn(['selection', 'annotation', 'range'], rangeSelections)
if(peekSelected && peekSelected.getIn(['track', 'id']) === track.get('id', null) && rangeSelections.isEmpty()) {
mState.setIn(['selection', 'annotation', 'pick'], pickSelections.add(selection).add(peekSelected))
} else {
mState.setIn(['selection', 'annotation', 'pick'], pickSelections.add(selection))
}
mState.setIn(['selection', 'annotation', 'selected'], selection)
}
})
}
case project.AnnotationSelectionType.Range: {
const source = selection.get('source', null)!
const track = selection.get('track', null)!
const filterByTrackFunc = (sel: Record<AnnotationSelection>) => {
return sel.get('track', null)!.get('id', null)! === track.get('id', null)
}
const annotation = selection.get('annotation', null)!
const annotations = track.get('annotationStacks', null).flatMap(stack => stack)
const sortFunc = (a1: Record<Annotation>, a2: Record<Annotation>) => {
return a1.get('utc_timestamp', null)! - a2.get('utc_timestamp', null)!
示例2:
layers: mapStyle.layers.filter(l => visible.has(l.id)),