duemunk / Async

Syntactic sugar in Swift for asynchronous dispatches in Grand Central Dispatch
MIT License
4.59k stars 316 forks source link

pass parameters through blocks #145

Closed MaxenceMax closed 4 years ago

MaxenceMax commented 4 years ago

Hi guys !

I found another issue which is talking about how to pass parameters through blocks, but I didn't find the answer to do something like that

func Appear(){
        Async.background {
            self.OccurrenceManager.getAllOccurrences { occs in
                // This block in main block
                self.occurrencesPublisher.send(occs.count)
            }
        }.main {
            // I want to achieve it here
        }
    }
duemunk commented 4 years ago

Async has not be created to solve indentation and nesting in your own calls. You might be able to have getAllOccurences return an Async instance. If you find a workable solution, feel free to share it here for future reference.