Corrected mistake:
func SignalsCallback(arg1 int, arg2 string, callback chan<- struct{})
SignalsCallback will only write to callback, not read.
Matt
On Monday, May 7, 2018 at 10:08:27 AM UTC-5, [email protected] wrote:
>
> Callbacks in Go can be done with a func argument to a func, or a similar
> effect can be made with channels by triggering a callback action by waiting
> on a blocking channel in the application. This Wikipedia article describes
> the pattern: https://en.wikipedia.org/wiki/Callback_(computer_programming)
>
> // this func executes callback at some point
> // you can specify any func signature for callback when you construct your
> own func that calls back
> func CallsBack(arg1 int, arg2 string, callback func())
>
> // this func sends a signal on callback that you listen for on another
> goroutine to execute your callback action
> // SignalsCallback may block until callback is read by you, or if the chan
> is buffered it may continue without callback being read
> func SignalsCallback(arg1 int, arg2 string, callback <-chan struct{})
>
> The difference is that CallsBack will execute callback in order, while
> SignalsCallback will continue concurrently after callback is read by your
> goroutine.
>
> Matt
>
> On Friday, May 4, 2018 at 7:53:13 PM UTC-5, Eduardo Moseis Fuentes wrote:
>>
>> HI everyone I´m Eduardo from Guatemala and I'm beginer. I'm interesting
>> in all scope golang in fact I was download a little book about it, but I
>> need learn more about callbacks because the book don´t has enough
>> information on callbacks. May somebody tell me where can I find more
>> information?. HELP ME PLEASE THANKS God Bless you
>>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.