Liking cljdoc? Tell your friends :D

precept.core


action-chclj/s

source

apply-additions-to-storeclj/s

(apply-additions-to-store in)

Reads ops from channel and applies additions to store

Reads ops from channel and applies additions to store
sourceraw docstring

apply-changes-to-sessionclj/s

(apply-changes-to-session in)
source

apply-removals-to-storeclj/s

(apply-removals-to-store in)

Reads ops from in channel and applies removals to store

Reads ops from in channel and applies removals to store
sourceraw docstring

batch-complete?clj/s

(batch-complete? event batch)

Returns true if the event is fire rules complete or it exists in the batch and the maximum event number received is equal to :total-events from fire rules complete

Returns true if the event is fire rules complete or it exists in the batch and
the maximum event number received is equal to `:total-events` from fire rules complete
sourceraw docstring

changes-multclj/s

source

changes-outclj/s

source

changes-xfclj/s

(changes-xf f)
source

connect-devtools-socket!clj/s

(connect-devtools-socket! options init-cb)
source

create-change-report-chclj/s

(create-change-report-ch)
(create-change-report-ch f)

Returns core.async channel with operational changes from session. Removes Precept implementation facts when called with no arguments. May be called with a function that will be applied to all :added and :removed facts.

Usage:

(def nil-values-ch
  (create-changes-report-ch
    (filter (fn [{:keys [e a v t]} record] (nil? v))
            %)))
(go-loop []
  (let [changes (<! nil-values-ch)]
    (println "Facts with nil values added / removed:" changes)))
=> Facts with nil values added / removed: {:added () :removed ()}
Returns core.async channel with operational changes from session.
Removes Precept implementation facts when called with no arguments.
May be called with a function that will be applied to all :added and :removed facts.

Usage:
```clj
(def nil-values-ch
  (create-changes-report-ch
    (filter (fn [{:keys [e a v t]} record] (nil? v))
            %)))
(go-loop []
  (let [changes (<! nil-values-ch)]
    (println "Facts with nil values added / removed:" changes)))
=> Facts with nil values added / removed: {:added () :removed ()}
```
sourceraw docstring

create-dto>socket-routerclj/s

(create-dto>socket-router in send! encoding)

Returns a go-loop that takes from a channel with events emitted by precept.listeners/PersistentSessionEventMessager and calls the provided send function, intended for use with a precept-devtools socket. Batches events per call tofire-rules`.

Returns a go-loop that takes from a channel with events emitted by
`precept.listeners/PersistentSessionEventMessager and calls the provided send function,
intended for use with a precept-devtools socket. Batches events per call to `fire-rules`.
sourceraw docstring

create-fired-session-chclj/s

(create-fired-session-ch)

Returns core.async channel that receives the session after the rules have been fired and before its listener has been replaced.

Returns core.async channel that receives the session after the rules have been fired and
before its listener has been replaced.
sourceraw docstring

default-devtools-optionsclj/s

source

default-groupclj/s

source

devtools-socket-chclj/s

source (clj)source (cljs)

devtools-socket-routerclj/s

source (clj)source (cljs)

dispatch!clj/s

(dispatch! f)
source

done-chclj/s

source

empty-batch?clj/s

(empty-batch? event batch)
source

groupsclj/s

source

handle-eventclj/smultimethod

source (clj)source (cljs)

handle-messageclj/smultimethod

source (clj)source (cljs)

identical-conditions-and-consequences-errorclj/s

(identical-conditions-and-consequences-error {:keys [existing-name type]})
source

init-session-chclj/s

source

init-transactorclj/s

(init-transactor)

Parks until session is initialized in (:session precept.state/state) then spawns a transactor that takes from action-ch.

Parks until session is initialized in (:session precept.state/state) then spawns
a transactor that takes from `action-ch`.
sourceraw docstring

lensclj/s

(lens a path)
source

matching-conditions-and-consequencesclj/s

(matching-conditions-and-consequences lhs rhs rules-index)
source

matching-consequencesclj/s

(matching-consequences rhs rule-index)
source

notify!clj/s

(notify! sub-name update-fn)
source

read-changes-from-sessionclj/s

(read-changes-from-session in)

Reads changes from session channel, fires rules, and puts resultant changes on changes channel. Updates session state atom with new session. Changes are returned keyed by :added, :removed as Tuple records.

Reads changes from session channel, fires rules, and puts resultant changes
on changes channel. Updates session state atom with new session. Changes are returned
keyed by :added, :removed as Tuple records.
sourceraw docstring

realized-sessionclj/s

source

registerclj/s

(register req)

Should only get called by subscribe, which determines if a sub exists.

Generates an id used to track requests and responses throughout the system.

req is a vector of name and params (currently we just support a name). Inserts subscription request into the current session. Responses are generated by subscription handler rules that match request name and insert facts into working memory. Subscriptions are stored in (:subscriptions @state). The lens is a reagent cursor that observes changes to the subscription's response that is written to the store.

Should only get called by `subscribe`, which determines if a sub exists.

Generates an id used to track requests and responses throughout the system.

`req` is a vector of name and params (currently we just support a name).
Inserts subscription request into the current session. Responses are generated by subscription
handler rules that match request name and insert facts into working memory.
Subscriptions are stored in (:subscriptions @state). The lens is a reagent cursor that
observes changes to the subscription's response that is written to the store.
sourceraw docstring

register-ruleclj/smultimethod

Returns rule name if found in registry, else registers new rule and returns name

Returns rule name if found in registry, else registers new rule and returns name
sourceraw docstring

removals-outclj/s

source

resume!clj/s

(resume! {:keys [session facts devtools] :as options})

Resets session with provided facts if start! has been called, otherwise returns the session received as an argument unmodified. Avoids duplicate session creation on page refresh in development when there is stale session metadata in the compiler.

Resets session with provided facts if `start!` has been called, otherwise returns the session
received as an argument unmodified. Avoids duplicate session creation on page refresh in
development when there is stale session metadata in the compiler.
sourceraw docstring

resume-with-devtools!clj/s

(resume-with-devtools! options)
source

session->storeclj/s

source

session-multclj/s

source

start!clj/s

(start! {:keys [id session facts devtools] :as options})

Initializes session with facts.

  • :session - Instance of clara.rules.engine.LocalSession created by precept.rules/session
  • :id - Value that uniquely identifies the session.
  • :facts - Vector. Initial facts to be inserted into the session
  • :devtools (optional) - Boolean or map of options for connecting to a running instance of a Precept devtools server. Default: nil. Supported devtools options:
    • :host - String with host and port separated by :. Defaults to default Devtools server address and port 0.0.0.0:3232.
    • :path - String of path for server socket. Defaults to default Devtools server path /chsk.
    • :encoding - Keyword of encoding for devtools socket. One of transit enc-types: :json, :json-verbose . Defaults to :json-verbose.
Initializes session with facts.

- `:session` - Instance of clara.rules.engine.LocalSession created by `precept.rules/session`
- `:id` - Value that uniquely identifies the session.
- `:facts` - Vector. Initial facts to be inserted into the session
- `:devtools` (optional) - Boolean or map of options for connecting to a
                           running instance of a Precept devtools server. Default: `nil`.
  Supported devtools options:
  - `:host` - String with host and port separated by `:`.
              Defaults to default Devtools server address and port `0.0.0.0:3232`.
  - `:path` - String of path for server socket.
              Defaults to default Devtools server path `/chsk`.
  - `:encoding` - Keyword of encoding for devtools socket.
                  One of transit enc-types: `:json`, `:json-verbose` . Defaults to
                  `:json-verbose`.
sourceraw docstring

start-with-devtools!clj/s

(start-with-devtools! {:keys [session facts devtools] :as options})
source

subscribeclj/s

(subscribe req)

Returns lens that points to a path in the store. Sub is handled by a rule.

Returns lens that points to a path in the store. Sub is handled by a rule.
sourceraw docstring

swap-session!clj/s

(swap-session! next)
source

swap-session-sync!clj/s

(swap-session-sync! next f)
source

thenclj/s

(then facts)

Inserts facts into current session

Inserts facts into current session
sourceraw docstring

traceclj/s

(trace & args)
source

transactorclj/s

(transactor)

Takes from action channel and puts to session->store channel. Parks until done-ch returns a message indicating:

  1. A transaction of facts (via then) was inserted into the (global) session ((:session precept.state/state))
  2. fire-rules was called on (:session precept.state/state)
  3. changes were read from the session and applied to the store
Takes from action channel and puts to `session->store` channel. Parks until `done-ch`
returns a message indicating:
  1. A transaction of facts (via `then`)  was inserted into the (global) session
     (`(:session precept.state/state)`)
  2. `fire-rules` was called on `(:session precept.state/state)`
  3. changes were read from the session and applied to the store
sourceraw docstring

update-session-historyclj/s

(update-session-history session)

First history entry is most recent

First history entry is most recent
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close