The sub()
function is used to subscribe to data from the server in TeamPlay. It can be used to subscribe to individual documents or to query multiple documents.
signal
: A signal representing the collection or document to subscribe to.queryParams
(optional): An object containing query parameters when subscribing to multiple documents.Returns a Promise that resolves to a signal representing the subscribed data.
sub()
function is asynchronous and returns a Promise.useSub()
hook instead, which handles the asynchronous nature of subscriptions in a React-friendly way.