Created
July 11, 2017 22:42
-
-
Save featheredtoast/eaca83c7be850cb751942a7d526d3021 to your computer and use it in GitHub Desktop.
figwheel-suspendable
This file contains hidden or 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
| (defrecord FigwheelSystem [system] | |
| component/Lifecycle | |
| (start [this] | |
| (if-not (:system-running this) | |
| (do | |
| (swap! system component/start) | |
| (assoc this :system-running true)) | |
| this)) | |
| (stop [this] | |
| (if (:system-running this) | |
| (do | |
| (swap! system component/stop) | |
| (assoc this :system-running false)) | |
| this)) | |
| fw-server/ChannelServer | |
| (-send-message [this channel-id msg-data callback] | |
| (fw-server/-send-message (:figwheel-server @system) | |
| channel-id msg-data callback)) | |
| (-connection-data [this] | |
| (fw-server/-connection-data (:figwheel-server @system))) | |
| (-actual [this] (:figwheel-server @system)) | |
| Suspendable | |
| (suspend [c] c) | |
| (resume [c old-s] | |
| (-> c | |
| (assoc :system-running (:system-running old-s)) | |
| (assoc :system (:system old-s))))) | |
| (defn figwheel-system [config-data] | |
| (let [{:keys [build-ids] :as options} | |
| (if (fw-config/figwheel-internal-config-data? config-data) | |
| (:data config-data) | |
| config-data) | |
| system | |
| (atom | |
| (-> (component/system-map | |
| :figwheel-server (fw-server/figwheel-server options)) | |
| (fw-sys/add-initial-builds (map name build-ids))))] | |
| (map->FigwheelSystem {:system system}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment