-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Ideas | ||
|
||
## Remote sources/signals | ||
|
||
Have the ability to have a shared graph between client/server. | ||
|
||
```clojure | ||
(ns server | ||
(:require | ||
[town.lilac.flex.core :as flex] | ||
[town.lilac.flex.remote.server :as flex.server])) | ||
|
||
|
||
(def *state (flex/source {:foo "bar"})) | ||
|
||
(def *foo (flex/signal (:foo @*state))) | ||
|
||
(def server | ||
(flex.server/serve | ||
;; available sources/signals | ||
{:state *state | ||
:foo *foo} | ||
;; config | ||
{:http/port 8888 | ||
:protocol :ws/http})) | ||
``` | ||
|
||
```clojure | ||
(ns client | ||
(:require | ||
[town.lilac.flex.core :as flex] | ||
[town.lilac.flex.remote.client :as flex.client])) | ||
|
||
(def client | ||
(flex.client/client | ||
{:port 8888 | ||
:protocol :ws/http})) | ||
|
||
;; signal to represent remote server state | ||
(def *state (flex.client/signal client :state)) | ||
|
||
;; can listen to/deref it like a normal signal | ||
(def *fooA (flex/signal (:foo @*state))) | ||
|
||
;; or listen to the remote server signal | ||
(def *fooB (flex.client/signal client :foo)) | ||
``` |