From 8be26fbf8b45f5ae9197ae7da716879bd1aba078 Mon Sep 17 00:00:00 2001 From: PJ Date: Sun, 26 Apr 2026 23:58:00 +0700 Subject: [PATCH] docs(spec): fix README example to use scoped extractors The previous snippet referenced `state.ax.find` inside an actions() body where state is not in scope, and shadowed the imported actions helper with an export of the same name. --- pkg/spec/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/spec/README.md b/pkg/spec/README.md index 6894b96..3b47883 100644 --- a/pkg/spec/README.md +++ b/pkg/spec/README.md @@ -13,10 +13,12 @@ npm install --save-dev @sanderling/spec ## Usage ```ts -import { extract, always, eventually, now, actions, weighted, taps, swipes, InputText, Tap } from "@sanderling/spec"; +import { extract, always, eventually, actions, weighted, taps, swipes, InputText, Tap } from "@sanderling/spec"; const loggedIn = extract((s) => !!s.ax.find("id:home-tab-bar")); const balance = extract((s) => (s.snapshots.balance as number) ?? 0); +const emailField = extract((s) => s.ax.find("id:email-field")); +const submitButton = extract((s) => s.ax.find("id:sign-in-button")); export const properties = { balanceNeverNegative: always(() => balance.current >= 0), @@ -25,13 +27,13 @@ export const properties = { const doLogin = actions(() => { if (loggedIn.current) return []; - const email = state.ax.find("id:email-field"); - const submit = state.ax.find("id:sign-in-button"); + const email = emailField.current; + const submit = submitButton.current; if (!email || !submit) return []; return [InputText({ into: email, text: "test@example.com" }), Tap({ on: submit })]; }); -export const actions = weighted( +export const actionsRoot = weighted( [50, doLogin], [10, taps], [2, swipes],