func init() { RegisterGlobalEvent(GLOBAL_TOPIC, util.JSONCodec(&testType{})) }
func init() { // GLOBAL_GOOGLE_STORAGE even will be fired with an instance of GoogleStorageEventData eventbus.RegisterGlobalEvent(GLOBAL_GOOGLE_STORAGE, util.JSONCodec(&GoogleStorageEventData{})) }
// JSONCallback is an adapter between a CallbackFn and a typed function // that deals with deserialized JSON data. // Example: // // fn := JSONCallback(&MyType{}, func(data interface{}, err error) { // ... data.(*MyType) // }) // fn(jsonBytes) // // This assumes that jsonBytes is valid JSON to deserialize to an // instance of MyType. // func JSONCallback(instance interface{}, callback func(data interface{}, err error)) CallbackFn { codec := util.JSONCodec(instance) return func(byteData []byte) { callback(codec.Decode(byteData)) } }