mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Use an interface for tasks instead of a concrete struct
By using an interface for tasks we can use a fake implementation in tests with extra methods
This commit is contained in:
@ -18,10 +18,10 @@ type AsyncHandler struct {
|
||||
lastId int
|
||||
mutex deadlock.Mutex
|
||||
onReject func()
|
||||
onWorker func(func(*gocui.Task))
|
||||
onWorker func(func(gocui.Task))
|
||||
}
|
||||
|
||||
func NewAsyncHandler(onWorker func(func(*gocui.Task))) *AsyncHandler {
|
||||
func NewAsyncHandler(onWorker func(func(gocui.Task))) *AsyncHandler {
|
||||
return &AsyncHandler{
|
||||
mutex: deadlock.Mutex{},
|
||||
onWorker: onWorker,
|
||||
@ -34,7 +34,7 @@ func (self *AsyncHandler) Do(f func() func()) {
|
||||
id := self.currentId
|
||||
self.mutex.Unlock()
|
||||
|
||||
self.onWorker(func(*gocui.Task) {
|
||||
self.onWorker(func(gocui.Task) {
|
||||
after := f()
|
||||
self.handle(after, id)
|
||||
})
|
||||
|
Reference in New Issue
Block a user