diff --git a/README.md b/README.md index 1ac4b30..eec0ed1 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,29 @@ await autoModeTopic.publish(); autoModeTopic.setValue('25 Ball Auto and Climb'); ``` +### Subscribing to Announced Topics + +You can register a callback to know when your topics are announced: + +```typescript +const ntcore = NetworkTables.getInstanceByTeam(973); +ntcore.addOnTopicAnnouncedListener((topic) => { + console.log(`Topic announced: ${topic.name}`); +}); +``` + +By supplying `true` to the `announceAll` parameter, all topics published to NetworkTables (from any client) will also be announced: + +```typescript +const ntcore = NetworkTables.getInstanceByTeam(973); +ntcore.addOnTopicAnnouncedListener((topic) => { + console.log(`Topic announced: ${topic.name}`); + topic.subscribe((value) => console.log(`Got ${topic.name} value: ${value}`)); +}, true); +``` + +This will allow you to subscribe to any or all topics from the robot, which is useful for dynamic dashboard applications. + ### More info The API for Topics is much more exhaustive than this quick example. Feel free to view the docs at [https://ntcore.chrislawson.dev](https://ntcore.chrislawson.dev). diff --git a/docs/assets/navigation.js b/docs/assets/navigation.js index a105119..7a5cb2d 100644 --- a/docs/assets/navigation.js +++ b/docs/assets/navigation.js @@ -1 +1 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE53UTU8CMRAG4P/SMxEhwQ9uGi8eRBLwZDx01wEalm7T6UY3xv9uAkTcdobZet333WenbbqvXyrAZ1BTNYPwUfvtUhcVoBoop8NGTVVZaUTAYSe+2IRdpQZqa+y7mo7GN98D2lnWzpQCtu/0F1sHj3ZVSyP+9s7J98Zq3z4Bol7Dgw76hBobwK90CThMWl1yPLn6Q95ZWze2hGP9BIbWAQ6jOJIub69HkzGvzbXXOxTMQ0mSO4uKxU4oSYzR823y0GKLLGXLycalDcmc+9qBDwaQWXVSyBbpM2Zqot4UlcENN2wnzbOYMYmO5C4giNtKdf7j0lPzTfEbTYGlNwV33eM812PmJVu97WcXTG159ZhL3v6/fdq3mItiUWsdzJpdohwe93l7Ebyxawo4JJLxYvX5f3dSyBbp42Rqsu7O3u44z/W4YamWbKNwU9JGvslNTPdo/+0HtFSZ1hIJAAA=" \ No newline at end of file +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAACp3UTU8CMRAG4P/SMxEhwQ9uGi8eRBLwZDx01wEalm7T6UY3xv9uAkTcdobZet333WenbbqvXyrAZ1BTNYPwUfvtUhcVoBoop8NGTVVZaUTAYSe+2IRdpQZqa+y7mo7GN98D2lnWzpQCtu/0F1sHj3ZVSyP+9s7J98Zq3z4Bol7Dgw76hBobwK90CThMWl1yPLn6Q95ZWze2hGP9BIbWAQ6jOJIub69HkzGvzbXXOxTMQ0mSO4uKxU4oSYzR823y0GKLLGXLycalDcmc+9qBDwaQWXVSyBbpM2Zqot4UlcENN2wnzbOYMYmO5C4giNtKdf7j0lPzTfEbTYGlNwV33eM812PmJVu97WcXTG159ZhL3v6/fdq3mItiUWsdzJpdohwe93l7Ebyxawo4JJLxYvX5f3dSyBbp42Rqsu7O3u44z/W4YamWbKNwU9JGvslNTPdo/+0HtFSZ1hIJAAA=" \ No newline at end of file diff --git a/docs/assets/search.js b/docs/assets/search.js index 7ae5446..1958e10 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE62bTW/bSBKG/wtz5TruT1q6JTMXA7vZYCYzF8EIaIl2CMukQFKeNQz/90VTlFjFKllFUacEZtdb1c2nulrd7LeoKv+po/niLXrKi1U0V/omjor0OYvm0bes+aesnn6k9+usjuJoW62jebRcp3Wd1Z/R06tfzfM6ivcPo3kUvcd7TX1te9HHrLkt6iYtltnX1x9Z+iwQ/sQZAVdxtEmrrGhIzJIY/vrjdnQIO5uREXitrD3EsFznob3A86HltB7L+3lW76C35a+0eMyEDmHjaT38XlaiAe2bTvCX13+U92XzW1kU2bLJVhLHjM3FIsiLx/Eh7IwmxJCuVkivLP6d101WZJUkmA+tx0XlnTP+ENbPn83rJpsWwtXxR/9SVwcPgjA/UPrg0dHkqrK0yX6Um3w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9PJmlM7z/rCvV+u/qH2LrD1HbdMdgPaazvSazog079vtPyY+lwCtZLzWqt1x7vU8eJeJjJHd9aJtlaO4QFgyle4OVi8BRkk2SGhvHgABhJTZ2XoZp7urHc3uLgZQVEBRiZQesybvLrfdvzbt/TqgB+TGqw1GXoM0kopt2stagIJew0s1BmHAvJFKdFvgoC/g1WkZBDmeDEAYShZHXsMZD88tINlkuYbF2tPXXg1MVLJ56ikNB2D33dEpeF2gl17Wy6f7/ak8kAH1wctyfy+T7k7mgBaYALxsBnhadaf0QAVkhpelRqdCA4JMy6B+yvdn9kAGpJeX5ddehoYEcPIynp7q7gwfqIAc8bIc6VRoQIBIL0MyXBraFYBV057ZgdwD3VOy7nEFGKhYmcruwAsEAlhUMhaL3RFu013M7rVAisgyBCnRSgJwUjKcsODrJsvb40pQN8GIGeGIcZp4zQLWBU5WPIkoFgT56GT5uDl8GMVxAvTsmXrMUg2uY2ToHD6iB28ETGNGNo2Ba2iAFvASlOwldDrMgBmQ7EaW7FiMjpYFklYsucUlW4MU07IcAzcXQP/g+lE2L4LLJ2m4fALEQFBGFtTuQ4bhpJgAFBJZwtdZswEfDIKgQNk3srKPtLgsAv200n5SSSaRgLATC9MFIVzdCoevv1wFdMAcqWVz5EGHGzbwVq0swYdyzJABUTdStNzfPAAxgqGzI4euQkoaBKZlgbWFD+d5AohIRqjwueDA1ONkUw9XOxWoIsrvDBPZ5BHkii36XWeAmpHVpLZOkjWeAWXIyMoQvFQJXh2ISMsi6oU48EFgdmxgx8kHE5uTTWzg6hwYNoC8kSF/0OEqJii/RlZ+h3JMzQSiVirKz2kgBbQsBYDSoOBpEJYeHRZHCijHVpZRVJBBBbxiJ3zF7V1rWloAdFoGHdFIQDSJQOMujjb5JlvnRRbNF3fv7/8HipGYPS5KAAA="; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAACr2bXW/byA6G/4t6q00z30nu2t2bAOd0i93u3hhBodhqKsSRDEnuniDofz8Y+UOkSNuUZ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hemCEORLLRy+/uAY0AE5Usty5F6HGzZwV61sgg/lmCEDom6kaLU7VQFiBENnRw5djZQ0fMSQBdYVPjzPAyAijFDh54IDqcfLUg9XOxWoIupmYxhkySPKlWv0XGeAmpHVpK5OkjWeAWXIyMoQPDAKbh2ISMsi6oU48EFgdmxgh8mHuweyxAaOBYJhg1sIMuT3OlxnQfm1svI7lGP6CkSdVJTPaWAKGNkUAErDggfCMqPD4gYPbgjIZhQVZIYP3GInvMXdOXJaWgB0WgYd0QggmiDQeEiTVbHKl0WZJ3ezh58//w/2Ql4ZhUwAAA=="; \ No newline at end of file diff --git a/docs/classes/NetworkTables.html b/docs/classes/NetworkTables.html index 7dac1d9..f8f1944 100644 --- a/docs/classes/NetworkTables.html +++ b/docs/classes/NetworkTables.html @@ -1,6 +1,7 @@
Gets the PubSubClient instance used to establish and manage the connection to the robot.
The PubSubClient instance.
-Adds a listener for robot connection status updates.
+Adds a listener for when topics are announced
+A callback triggered with the announced topic
+Optional
announceAll: booleanWhether to trigger all topics in NetworkTables to be announced
+A function to remove the listener.
+Adds a listener for robot connection status updates.
The callback to call when the connection status changes.
Optional
immediateNotify: booleanWhether to immediately notify the callback of the current connection status.
A function to remove the listener.
-Creates a new topic.
+Creates a new topic.
The name of the topic.
The type information of the topic.
Optional
defaultValue: TThe default value of the topic.
The topic.
-Returns the port to connect to the robot on.
+Returns the URI of the server.
+Returns whether the robot is currently connected.
+Returns whether the robot is currently connecting.
+Static
getCreates a new NetworkTables instance if it does not exist.
+Static
getCreates a new NetworkTables instance if it does not exist.
The team number of the robot.
The port to connect to the robot on. Defaults to 5810.
The NetworkTables instance.
Static
getCreates a new NetworkTables instance if it does not exist.
+Static
getCreates a new NetworkTables instance if it does not exist.
The URI of the robot.
The port to connect to the robot on. Defaults to 5810.
The NetworkTables instance.
NetworkTables class for interacting with NetworkTables over a WebSocket connection.
-