update.esl 526 B

1234567891011121314
  1. (lambda (new-state)
  2. (= new-state (JSON.parse new-state))
  3. (.map (Object.keys new-state) (lambda (device-type-name)
  4. (var device-type (introduce device-type-name))
  5. (var new-devices (get new-state device-type-name))
  6. (.map (Object.keys new-devices) (lambda (device-id)
  7. (device-type.put device-id (get new-devices device-id))))))
  8. (function introduce (device-type)
  9. (if (! (get /state/session device-type))
  10. (/state/session/put device-type (object)))
  11. (return (/state/session/get device-type))))