api.getReactiveState()
Description
Gets an object with the reactive properties of Kanban
Usage
api.getReactiveState(): object;
Returns
The method returns an object with the following parameters:
{
areasMeta: {
subscribe: any,
update: any,
set: any
},
before: {...},
cardHeight: {...},
cardShape: {...},
cards: {...},
cardsMap: {...},
cardsMeta: {...},
columnKey: {...},
columnShape: {...},
columns: {...},
currentUser: {...},
dragItemId: {...},
dragItemsCoords: {...},
edit: {...},
history: {...},
layout: {...},
links: {...},
overAreaId: {...},
readonly: {...},
rowKey: {...},
rowShape: {...},
rows: {...},
scroll: {...},
search: {...},
selected: {...},
sort: {...}
}
Example
// create Kanban
const board = new kanban.Kanban("#root", {
columns,
cards,
rows
});
// get the Reactive State of Kanban
const state = board.api.getReactiveState();
// subscribe on the columns changes and output the array of columns
state.columns.subscribe((data) => {
console.log(data);
});
// subscribe on the cards changes and output the array of cards
state.cards.subscribe((data) => {
console.log(data);
});
// subscribe on the rows changes and output the array of rows
state.rows.subscribe((data) => {
console.log(data);
});
// subscribe on the card selection and output the IDs of the selected cards
state.selected.subscribe((data) => {
console.log(data);
});
// set new selection
state.selected.set([1, 2]);
// update selection
state.selected.update((data) => {
data.push(3);
return data;
});
Change log: The method was updated in v1.4