Closed ahdong2007 closed 4 years ago
if table.addedItem is set, we will remove it before we reset it. so table.addedItem will be always just one item, it didn't need to be a array. table.aboutToDeleteItem is the same.
`func (table CacheTable) SetAddedItemCallback(f func(CacheItem)) {
// 如果已存在回调函数,则置空 if len(table.addedItem) > 0 { table.RemoveAddedItemCallbacks() } table.Lock() defer table.Unlock() table.addedItem = append(table.addedItem, f)
}`
That's intentional. If you want to use multiple callbacks, you can use AddAddedItemCallback.
AddAddedItemCallback
if table.addedItem is set, we will remove it before we reset it. so table.addedItem will be always just one item, it didn't need to be a array. table.aboutToDeleteItem is the same.
`func (table CacheTable) SetAddedItemCallback(f func(CacheItem)) {
}`