Lavash.Optimistic.ActionJs (Lavash v0.3.0-rc.2)

Copy Markdown View Source

Shared action analysis and JS generation for optimistic updates.

Used by both ColocatedTransformer (compile-time) and JsGenerator (runtime).

Summary

Functions

Checks if an action has transpilable client-side operations (sets/updates).

Analyze a value to determine how to generate JS for it.

Normalize a dependency to its root field name as a string.

Functions

action_is_optimistic?(action)

Checks if an action has transpilable client-side operations (sets/updates).

Actions with effects, submits, navigates, or invokes can still be partially optimistic — the sets run client-side immediately while the server handles the side effects.

analyze_value(value)

Analyze a value to determine how to generate JS for it.

Returns:

  • {:rx, source} for rx() expressions
  • {:literal, value} for simple literals
  • :from_params_value for param accessors
  • :unknown for non-transpilable values

normalize_dep_to_string(atom)

Normalize a dependency to its root field name as a string.

Path deps like {:path, :params, ["name"]} become "params". Atom deps like :count become "count".