This guide will walk you through the basic concepts and usage of TeamPlay.
In TeamPlay, data is organized into collections. There are two types:
Public Collections: These are shared across all users of your app. They typically start with a lowercase letter (e.g., users
, posts
).
Private Collections: These are specific to each user or session. They start with an underscore (e.g., _session
).
Every signal in TeamPlay comes with a set of useful methods:
.get()
: Retrieves the current value of the signal..set(value)
: Updates the value of the signal..del()
: Deletes the value (or removes an item from an array).Example:
$()
Function: Creating Local SignalsThe $()
function is a powerful tool for creating local, reactive values:
sub()
Function: Subscribing to DataThe sub()
function is used to subscribe to data from the server:
Query signals are special. They behave like a collection signal, but they're also iterable:
Each $user
in the loop is a scoped signal for that specific user document.
TeamPlay's reactivity system ensures that whenever data changes, any part of your app using that data updates automatically. This happens behind the scenes, so you don't have to manually track and update data dependencies.
For example, if you're displaying a user's name in your app and that name changes in the database, TeamPlay will automatically update your app's UI to reflect the new name.
This reactivity works for both public and private collections, local signals created with $()
, and subscribed data from sub()
.
By using these tools and concepts, you can build powerful, real-time applications with ease using TeamPlay!