Understanding Encode and Decode for User Data Transformation and Event Publishing
I'm trying to get my head around decode and enconde.
My scenario is that I have some user data I grab from DB and that becomes a User type. Then I transform this user data and publish this to event bus for someone else to consume. My issue is about sending this data.
I started with:
This allows me to
But then looking at the docs,
So I changed the schema to:
with
The reason why I started with the first approach is because I wouldn't ever receive that
But semantically the secod approach is correct??!!!
Am I on the right track with the second option?
My scenario is that I have some user data I grab from DB and that becomes a User type. Then I transform this user data and publish this to event bus for someone else to consume. My issue is about sending this data.
I started with:
This allows me to
yield* SCH.decode(UserTelemetry)(user) and send the result to the event bus.But then looking at the docs,
decode is for when receiving data from outside and encode to send the data.So I changed the schema to:
with
yield* SCH.encode(UserTelemetry)(user).The reason why I started with the first approach is because I wouldn't ever receive that
user_*** format in order to decode.But semantically the secod approach is correct??!!!
Am I on the right track with the second option?
