FAQ
I'm trying to make a small, scalable event-subscription system based on
channels. It is a simple struct with two fields. A channel called trigger,
and a []channel called subscriptions.
type event struct {
trigger channel
subscriptions []channel
}
Is there a void type? In my event listener function, I try to pull from the
trigger channel, then for each channel in the subscriptions array I would
make a copy of the data and send that sopy to each subscription.

Is there a way to, rather than trying to deal with a void types, abstract
this struct so that anyone using this would have to create a event[<type>]
where <type> would be the data they want to send? For example if they want
to send an int to all subscribed channels it would be a event[int]

--
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 golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Kyconquers at Jan 24, 2015 at 8:05 am
    Or would it be better practice to have an Interface called event_packet and
    only allow structs that implement the event_packet interface to be passed?

    --
    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 golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Tamás Gulácsi at Jan 24, 2015 at 8:54 am
    There is interface{}, but do you really need such a generic thing? You loose static type checking and have to you type asserts.

    --
    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 golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 24, '15 at 8:04a
activeJan 24, '15 at 8:54a
posts3
users2
websitegolang.org

2 users in discussion

Kyconquers: 2 posts Tamás Gulácsi: 1 post

People

Translate

site design / logo © 2022 Grokbase