-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: add prefix topics #158
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #158 +/- ##
========================================
Coverage ? 87.50%
========================================
Files 0 10 +10
Lines 0 704 +704
Branches 0 137 +137
========================================
+ Hits 0 616 +616
- Misses 0 88 +88 ☔ View full report in Codecov by Sentry. |
@cjlawson02 |
BREAKING CHANGE: removes immediateNotify from topic subscription
9955c19
to
830f831
Compare
473aa79
to
27205e6
Compare
This is great, however it does not seem to be compatible with the topicsOnly flag, I only want to receive the names/types of all topics, not all of the data from them, is there some way to do this? When I subscribe to a prefix key with topicsOnly: true, the callback never gets called. |
Also, I noticed that if I am subscribing to a prefix topic of "/" that normal subscriptions stop working (never recieve updates for them). As soon as I comment out |
Thanks for letting me know, I'll try to get some time this weekend to spin up a simulator to test this |
Sounds good, thanks for your work on this |
@cjlawson02 I can confirm that the change did work for me! Thank you! 🥳 This worked for me to listen for all the topics and add all the values into a Redux store: const client = NetworkTables.getInstanceByURI('localhost'); // Simulator
const allTopics = client.createPrefixTopic('/');
allTopics.subscribe((value, params) => {
const topicName = params.name;
const entryExists = !!store.getState().nt.data[topicName];
if (!entryExists ) {
store.dispatch(addNTEntry({topicName, type: params.type}))
}
store.dispatch(updateNTValue({topicName, value}));
}); For the record - I tested @nab138's issue with the prefix and normal subscribe and I wasn't able to reproduce the problem: const client = NetworkTables.getInstanceByURI('localhost'); // Simulator
const allTopics = client.createPrefixTopic('/');
allTopics.subscribe((value, params) => {
const topicName = params.name;
if (topicName === '/Shuffleboard/Logging/timeMs') {
console.log('prefix nt value', value);
}
});
client.createTopic<number>('/Shuffleboard/Logging/timeMs', NetworkTablesTypeInfos.kInteger)
.subscribe(value => console.log('NOT prefix nt value', value)); |
@nab138 can you provide a minimal reproducible example please? |
Fixes #30
BREAKING CHANGE to add support for prefix topics
Users can subscribe to any path (root or subpath) to receive value updates to their callback