Skip to content

Differences from standard Pinia ​

unix-pinia aligns with standard Pinia's feature surface and usage habits. Because UTS compiles to Kotlin/Swift without Proxy and without reflective field enumeration, and recent HBuilderX compilers fail to generate Kotlin imports for runtime-class vue symbols (Ref / watch / effectScope) inside UTS plugins, some capabilities take a different form or are pruned — each listed below.

Architecture form differences ​

Standard Piniaunix-piniaReason
setup-style or Options-style defineStoreclass-style: class XxxStore extends PiniaStoreBaseclass + reactive is the only viable architecture for a full $-API inside a plugin
state in any shape (ref / reactive mixed)state is a class field wrapped in strongly-typed reactive<T> (primitive-value fields)UTS has no Proxy and the Ref-unwrapping behavior is inconsistent across platforms; reactive is compile-time expanded and consistent
getter = computedderived values = class getterseffectScope is unavailable inside plugins and computed stops working across pages; getters are evaluated per access with no lifecycle issues
script access store.countstore.state.count (no .value)state is a strongly-typed reactive object; scripts and templates share the same path
return type auto-inferredfactory return type annotated explicitly (a class instance)UTS inference is limited; explicit annotation is safer

Instance API differences ​

Standard Piniaunix-piniaNotes
$patch(fn) / $patch(partial)$patch(partial: UTSJSONObject) — object form onlyno Partial<T> inference; loading goes through the _hydrate hook and stays type-safe
$subscribe(cb) fires on any change$subscribe(cb) fires only on $patch / $reset / $saveUTS has no global field-subscription hook; call $save() after direct mutations
$onAction tracks all actions automaticallyonly actions wrapped with callAction are trackedUTS cannot wrap methods automatically
$state = { ... } whole replacement$state is a reference (same as store.state); reassigning only swaps the reference and triggers neither subscriptions nor persistencea reactive object cannot be cast wholesale; mutate per field + $patch
$reset() built in (Options stores)$reset() is defined by the _doReset hookstandard Pinia does not build it in for setup stores either
plugins may return an object merged into the storeplugins return void, hook logic onlyUTS forbids injecting properties into existing objects dynamically

Pruned APIs ​

APIReasonReplacement
Options-style defineStorethis in UTS is limited to class methods (the class style already covers that form)class-style defineStore
Options helpers like mapStatecomposition is the mainstream; spread injection is unverifiedaccess store.state.x and getters directly
devtools / HMR / SSR / acceptHMRUpdateno corresponding mechanism on native—

Behavioral parity (not pruned) ​

ItemNotes
required idstandard Pinia's id inference relies on Symbol/SSR context
same-id idempotencyduplicate defineStore warns and returns the existing instance
multiple Pinia instancesone globally unique store registry (uni-app x apps have no multi-instance isolation scenario); createPinia instances carry plugins and the active flag

Mounting difference ​

app.use(pinia) does not fire install on native (verified) — unix-pinia adopts mount-free as the only reliable form: it works with zero mounting code; for plugins, top-level setActivePinia(createPinia().use(plugin)).

Template binding difference ​

Template event bindings to class methods must include parentheses: @click="counter.increment()" — a method is not a value on Kotlin (Web's first-class JS functions mask the difference).

Released under the MIT License.