本文整理匯總了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 {
//.........這裏部分代碼省略.........