Skip to content

Commit

Permalink
Merge pull request #26 from ghivert/fix/fix-target-in-erlang
Browse files Browse the repository at this point in the history
Fix correct signature for `cache` on Erlang target
  • Loading branch information
ghivert authored Sep 17, 2024
2 parents 34b2416 + 1707d31 commit c4814eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions sketch/src/sketch/error.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//// Defines standard error returned by sketch.

import gleam/otp/actor

/// NotABrowser is unused nowadays. It will be removed in v4.
pub type SketchError {
NotABrowser
OtpError(actor.StartError)
}
9 changes: 6 additions & 3 deletions sketch/src/sketch/internals/cache/setup.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import gleam/list
import gleam/otp/actor
import gleam/pair
import gleam/result
import sketch/error.{type SketchError}
import sketch/internals/cache/state
import sketch/internals/style

Expand All @@ -21,9 +22,11 @@ pub fn ephemeral() {
}

@target(erlang)
pub fn persistent() -> Result(Cache, Nil) {
let assert Ok(subject) = actor.start(style.persistent(), state.loop)
Ok(PersistentCache(subject))
pub fn persistent() -> Result(Cache, SketchError) {
let subject = actor.start(style.persistent(), state.loop)
subject
|> result.map(PersistentCache)
|> result.map_error(error.OtpError)
}

@target(erlang)
Expand Down

0 comments on commit c4814eb

Please sign in to comment.