Ash FrameworkAF
Ash Framework7mo ago
16 replies
Failz

code_interface, compile time vs runtime

if this were a code_interface, is timestamp captured once at compile time and all future calls use that compiled timestamp value? If yes, is there a different way to solve this? I've got multiple live views calls this code_interface and I'm wanting to keep all the logic in one place

      define :get_budget_with_accounts,
        action: :read,
        get_by: [:id],
        default_options: [
          load: [
            :total_balance,
            accounts:
              App.Finance.Account
              |> Ash.Query.load(:balance_as_of, timestamp: DateTime.utc_now())
              |> Ash.Query.sort(:identifier)
          ]
        ]
Solution
i.e default_options: fn -> ... end
Was this page helpful?