Developer docs SDK

Reactive state

Typed stores with change tracking, persisted across runs via the platform backend — silently degrading to in-memory mode when the backend is unreachable.

Python

from allybuild_sdk.reactive import defineStore, getter, action, field

@defineStore("review-queue")
class ReviewQueue:
    items: list = field(default_factory=list)

    @getter
    def pending(self) -> int:
        return sum(1 for i in self.items if not i["done"])

    @action
    def add(self, path: str) -> None:
        self.items = self.items + [{"path": path, "done": False}]

queue = ReviewQueue()
queue.add("src/auth.py")

TypeScript

import { defineStore } from "@allybuild/sdk";

const useCounter = defineStore("counter", {
  state: () => ({ count: 0 }),
  getters: { doubled: (s) => s.count * 2 },
  actions: { inc() { this.count += 1; } },
});

const counter = useCounter();
counter.inc();

Dollar API

MethodPurpose
$patch(dict | fn)Batch update producing one "patch" mutation
$reset()Restore defaults, emits "reset"
$subscribe(cb)Watch mutations; returns an unsubscribe fn
$on_action(cb) / $onActionAction lifecycle hooks
$atomic(fn) / $load()Single-event multi-field update / pull persisted state
$stateDeep-copied read-only snapshot
$dispose()Detach subscribers and remove

Named statuses

project_status exposes one reactive store per named status. Access a store by name — missing names start empty, seeded from the status schema:

deploy = project_status.get("deploy")
deploy["last_run"] = TASK_ID
const deploy = project_status.get("deploy");
deploy.lastRun = TASK_ID;

HTTP persistence

from allybuild_sdk.reactive import HttpBackend, create_reactive

backend = HttpBackend(
    api_url=ALLYBUILD_API_URL,
    jwt=TASK_JWT,
    project_id=PROJECT_ID,
)
create_reactive(redis=backend)
createReactive({
  backend: new HttpBackend({
    apiUrl: ALLYBUILD_API_URL,
    jwt: TASK_JWT,
    projectId: PROJECT_ID,
  }),
});

Plugins

get_reactive().use(action_logger_plugin)    // log every action call
get_reactive().use(persistence_plugin)     # persist store changes through the backend

Errors

  • AllyBuildError(status, message) — HTTP failures
  • ReactiveError base, with InvalidStateKeyError / StoreNotFoundError / StoreDisposedError