本文整理汇总了Golang中kego/io/flux.Payload.NotifyWithData方法的典型用法代码示例。如果您正苦于以下问题:Golang Payload.NotifyWithData方法的具体用法?Golang Payload.NotifyWithData怎么用?Golang Payload.NotifyWithData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kego/io/flux.Payload
的用法示例。
在下文中一共展示了Payload.NotifyWithData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Handle
func (s *BranchStore) Handle(payload *flux.Payload) bool {
previous := s.selected
switch action := payload.Action.(type) {
case *actions.ChangeView:
s.view = action.View
s.selected = s.Root()
payload.Notify(nil, ViewChanged)
case *actions.Add:
payload.Wait(s.app.Nodes)
switch action.Direction() {
case actions.New, actions.Redo:
child, parent, err := mutateAppendBranch(s, action.Parent, action.Node, action.BranchName, action.BranchFile)
if err != nil {
s.app.Fail <- kerr.Wrap("LDBMBRHWHB", err)
break
}
if child != nil {
if ancestor := child.EnsureVisible(); ancestor != nil {
payload.NotifyWithData(ancestor, BranchOpened, &BranchDescendantSelectData{
Branch: child,
Op: models.BranchOpChildAdded,
})
}
s.selected = child
payload.Notify(previous, BranchUnselectControl)
payload.Notify(s.selected, BranchSelectControl)
payload.Notify(s.selected, BranchSelected)
}
if parent != nil {
payload.Notify(parent, BranchChildAdded)
}
case actions.Undo:
_, parent, err := mutateDeleteBranch(s, action.Node)
if err != nil {
s.app.Fail <- kerr.Wrap("NLFWVSNNTY", err)
break
}
if parent != nil {
payload.Notify(parent, BranchChildDeleted)
s.selected = parent
payload.Notify(previous, BranchUnselectControl)
payload.Notify(s.selected, BranchSelectControl)
payload.Notify(s.selected, BranchSelected)
}
}
case *actions.Delete:
payload.Wait(s.app.Nodes)
switch action.Direction() {
case actions.New, actions.Redo:
branch, parent, err := mutateDeleteBranch(s, action.Node)
if err != nil {
s.app.Fail <- kerr.Wrap("QTXPXAKXHH", err)
break
}
if branch != nil {
action.BranchIndex = branch.Index
if nci, ok := branch.Contents.(models.NodeContentsInterface); ok {
action.BranchName = nci.GetName()
}
if fci, ok := branch.Contents.(models.FileContentsInterface); ok {
action.BranchFile = fci.GetFilename()
}
}
if parent != nil {
payload.Notify(parent, BranchChildDeleted)
s.selected = parent
payload.Notify(previous, BranchUnselectControl)
payload.Notify(s.selected, BranchSelectControl)
payload.Notify(s.selected, BranchSelected)
}
case actions.Undo:
child, parent, err := mutateInsertBranch(s, action.Parent, action.Node, action.BranchIndex, action.BranchName, action.BranchFile)
if err != nil {
s.app.Fail <- kerr.Wrap("OOGOEWKPIL", err)
break
}
if child != nil {
if ancestor := child.EnsureVisible(); ancestor != nil {
payload.NotifyWithData(ancestor, BranchOpened, &BranchDescendantSelectData{
Branch: child,
Op: models.BranchOpChildAdded,
})
}
s.selected = child
payload.Notify(previous, BranchUnselectControl)
payload.Notify(s.selected, BranchSelectControl)
payload.Notify(s.selected, BranchSelected)
}
if parent != nil {
payload.Notify(parent, BranchChildAdded)
}
}
case *actions.Reorder:
payload.Wait(s.app.Nodes)
parent, err := mutateReorderBranch(s, action.Model.Node)
if err != nil {
s.app.Fail <- kerr.Wrap("NUQOPWWXHA", err)
break
}
if parent != nil {
//.........这里部分代码省略.........