CoNarrative / precept

A declarative programming framework
MIT License
657 stars 33 forks source link

Clean todomvc example and rename project #39

Closed alex-dixon closed 7 years ago

alex-dixon commented 7 years ago

Minimize def-tuple-session boilerplate

(cr/defsession app-session 'precept.todomvc.rules :fact-type-fn :a :ancestors-fn ancestors-fn :activation-group-fn activation-group-fn :activation-group-sort-fn activation-group-sort-fn)

- When no schema supplied, `make-ancestors-fn` is called with no arguments, which will entail a one to one relationships for all facts.

**Add implementation-level rules ns**
- Include rules defined in `impl.rules` in every session definition. These are intended to be rules we previously used in every session and that are essential to the implementation, such as action cleanup. The ns currently includes this rule as well as cleanup of any facts with eid of `:transient`, which may replace the "action" fact type in the near future.

**Add facts from the view**
- Redefined `then` as `insert`:
```clj
(defn then
  "Inserts facts into current session"
  [facts]
  (dispatch! (fn [session] (util/insert session facts))))

When there is something for which we only care to know the current value (if one exists), we insert a transient fact:

:on-key-down #(then [:transient :input/key-code (.-which %])

Any fact with the eid :transient will last one rule firing.

Clean up todomvc example