Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rstream] subscribeTopic and transformTopic return incorrect type and incorrect values #288

Open
miraklez opened this issue May 12, 2021 · 1 comment

Comments

@miraklez
Copy link

This exemple use a MQTT Broker to stream temperature from all sensors in a main stream, based on topic value.

type Event = { topic: string, value: number }
const main = pubsub({topic: (e: Event) => e.topic });

if i use subscribeTopic and xform to get only the value data

const outside = main.subscribeTopic('outside', { xform: map((e) => e.value)});
const room = main.subscribeTopic('room', { xform: map((e) => e.value) });
outside.subscribe(trace('outside'));
room.subscribe(trace('room'));

results

outside { topic: 'outside', value: 11 }
room { topic: 'room', value: 17 }
outside { topic: 'outside', value: 11 }
room { topic: 'room', value: 17 }

xform seems to not be applied at all but type for outside and room is correct ISubscription<Event, number>

but if i use transformTopic

const outside = main.transformTopic('outside', map((e) => e.value));
const room = main.transformTopic('room', map((e) => e.value));
outside.subscribe(trace('outside'));
room.subscribe(trace('room'));

results

outside 12
room 17
outside 12

it's the opposite.
i have correct values using trace but type for outside and room is incorrect ISubscription<Event, Event> instead of ISubscription<Event, number>

Using "@thi.ng/rstream": "^6.0.8",

Any pointers?

@miraklez miraklez changed the title [rstream] subscribeTopic and transformTopic` return incorrect type and incorrect values [rstream] subscribeTopic and transformTopic return incorrect type and incorrect values May 12, 2021
@postspectacular
Copy link
Member

Hi @miraklez - am moving house this week and alas can't look into this right now. will get back to you asap (next week some time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants