A Group categorizes and preserves the ordering of structured data in a Collection.
They allow us to cluster together data from a Collection as an array of
A Group doesn't store the actual Items. It only keeps track of the
and retrieves the fitting Items from the Collection when needed.
We instantiate a Group with the help of an existing Collection. By doing so, the Group is automatically bound to the Collection it was created from and has access to its data. A Group can be created during the creation of a Collection in the configuration object.
Or dynamically, after the Collection has been defined.
The Collection can have as many Groups as we want and won't lose its redundant behavior. This is due to the fact that each Item is stored in the Collection itself and not in the Group. You can imagine a Group like an interface to the Collection Data.
The cool thing about Groups is that they are an extension of the
and offers the same powerful features.
But be aware that the
value might not be the output you expect.
In a Group, the
value property manages the
primaryKeys a Group represents.
To get the Item Value to each
primary Key, we use the
If you want to find out more about specific methods of the Group, checkout the Methods Section. Most methods we use to modify, mutate and access the Group are chainable.
For instance, we can use a Group to cluster a Post Collection into User Posts of the logged-in user.
In the above code snippet, we have two Collections, one for users and another for posts. We can collect posts specific to a user and group them automatically by the user's id.
Test the Group yourself. It's only one click away. Just select your preferred Framework below.
- Vue (coming soon)
- Angular (coming soon)
itemKeys of the initial Items, the Group represents.
Beside the initial îtemKeys a
Group takes an optional configuration object.
Here is a Typescript Interface for quick reference. However, each property is explained in more detail below.
The optional property
key/name should be a unique
string/number to identify the Group later.
We recommend giving each Group a unique
key, since it has only advantages:
- helps us during debug sessions
- makes it easier to identify the Collection
- no need for separate persist Key
This property is mainly thought for internal use.
Defines whether the Group is an
placeholder or not.
Groups are, for example,
placeholder when AgileTs needs to hold a reference to them,
although they aren't instantiated yet.
This might be the case by using
which returns a
placeholder Group, if the Group doesn't exist,
to hold a reference to it.
This reference is essential to rerender the Component, whenever the Group got instantiated.
Group Class is almost 100% typesafe.