From 26721cd2275b35556da8c48c481c9c82ac821575 Mon Sep 17 00:00:00 2001 From: Nick Cuthbert Date: Tue, 17 Apr 2018 14:26:11 +0200 Subject: [PATCH] Fixed build --- package.json | 2 +- src/Nact.js | 26 +++++++++++++++++++------- src/Nact.re | 4 +++- src/Nact.rei | 1 + 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index a70f859..a2d3a85 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "test-watch": "jest --coverage --watch", "coverage": "nyc report --temp-directory=coverage --reporter=text-lcov | coveralls", "pretest": "yarn run build", - "prepush": "yarn run local-test", + "prepush": "yarn run build && yarn run local-test", "prepare": "yarn run clean && yarn run build" }, "keywords": [ diff --git a/src/Nact.js b/src/Nact.js index 7e332c4..9489409 100644 --- a/src/Nact.js +++ b/src/Nact.js @@ -8,6 +8,7 @@ var $$String = require("bs-platform/lib/js/string.js"); var Js_option = require("bs-platform/lib/js/js_option.js"); var Caml_int32 = require("bs-platform/lib/js/caml_int32.js"); var Nact_jsMap = require("./Nact_jsMap.js"); +var Belt_Option = require("bs-platform/lib/js/belt_Option.js"); var Js_primitive = require("bs-platform/lib/js/js_primitive.js"); var Belt_SetString = require("bs-platform/lib/js/belt_SetString.js"); var Caml_exceptions = require("bs-platform/lib/js/caml_exceptions.js"); @@ -55,10 +56,15 @@ function toString(param) { return "system:" + (path.system + ("//" + $$String.concat("/", path.parts))); } +function parts(param) { + return param[0].parts; +} + var ActorPath = /* module */[ /* fromReference */fromReference, /* systemName */systemName, - /* toString */toString + /* toString */toString, + /* parts */parts ]; @@ -349,12 +355,18 @@ function spawnPersistent(key, name, shutdownAfter, snapshotEvery, onCrash, decod var decoder$1 = defaultTo((function (prim) { return unsafeDecoder(prim); }), decoder); - var stateDecoder$1 = defaultTo((function (prim) { - return unsafeDecoder(prim); - }), stateDecoder); - var stateEncoder$1 = defaultTo((function (prim) { - return unsafeEncoder(prim); - }), stateEncoder); + var match = Belt_Option.isSome(snapshotEvery); + var stateDecoder$1 = defaultTo(match ? (function (prim) { + return unsafeDecoder(prim); + }) : (function (prim) { + return prim; + }), stateDecoder); + var match$1 = Belt_Option.isSome(snapshotEvery); + var stateEncoder$1 = defaultTo(match$1 ? (function (prim) { + return unsafeEncoder(prim); + }) : (function (prim) { + return prim; + }), stateEncoder); var encoder$1 = defaultTo((function (prim) { return unsafeEncoder(prim); }), encoder); diff --git a/src/Nact.re b/src/Nact.re index 8e2bfd3..4adf7cb 100644 --- a/src/Nact.re +++ b/src/Nact.re @@ -77,6 +77,8 @@ function unsafeDecoder(result) { external magicDecoder : Js.Json.t => 'msg = "%identity"; +external magicEncoder : 'msg => Js.Json.t = "%identity"; + [@bs.val] external unsafeEncoder : 'msg => Js.Json.t = "unsafeEncoder"; module Log = { @@ -361,7 +363,7 @@ let spawnPersistent = let stateEncoder = stateEncoder |> defaultTo( - Belt.Option.isSome(snapshotEvery) ? unsafeDecoder : magicDecoder, + Belt.Option.isSome(snapshotEvery) ? unsafeEncoder : magicEncoder, ); let encoder = encoder |> defaultTo(unsafeEncoder); let options: Nact_bindings.persistentActorOptions('msg, 'parentMsg) = { diff --git a/src/Nact.rei b/src/Nact.rei index 2700add..0760a0f 100644 --- a/src/Nact.rei +++ b/src/Nact.rei @@ -18,6 +18,7 @@ module ActorPath: { let fromReference: actorRef(_) => actorPath; let systemName: actorPath => string; let toString: actorPath => string; + let parts: actorPath => list(string); }; module Log: {