Transform the items emitted by an Observable by applying an unmarshaller function (func([]byte, interface{}) error
) to each item. It takes a factory function that initializes the target structure.
observable := rxgo.Just(
[]byte(`{"id":1}`),
[]byte(`{"id":2}`),
)().Unmarshal(json.Unmarshal,
func() interface{} {
return &customer{}
})
Output:
&{ID:1}
&{ID:2}