;; next/genesis/object-types/define-projection.sx
;;
;; Meta-object that registers a new projection. The projection
;; scheduler (Step 7) spawns one gen_server per registered
;; projection and feeds activities through its :fold body in
;; sandbox mode.

(DefineObject
  :name "DefineProjection"
  :doc "Projection registration. :name is the projection key;\n        :initial-state is the empty state value; :fold is the\n        pure (state activity) -> state function evaluated in\n        sandbox mode per activity."
  :schema (fn
    (obj)
    (and
      (string? (-> obj :name))
      (not (nil? (-> obj :initial-state)))
      (not (nil? (-> obj :fold))))))
