Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

How can i bind this?

$
0
0

Not sure I fully follow what you’re after, but here’s an example:

module Storage = {
  // TODO: Fill in
  type t = unit
}

module StorageManager = {
  type t

  type redisConfig = {prefix?: string, password?: string, ip?: string}
  type config = {redis?: redisConfig}

  @new @module("xyz")
  external make: config => t = "default"

  @send external storage: (t, {..}) => Storage.t = "Storage"
}

let storageManager = StorageManager.make({
  redis: {prefix: "storage:file:", password: "password", ip: "ip"},
})

storageManager->StorageManager.storage({"path": "test"})

Compiles to:

// Generated by ReScript, PLEASE EDIT WITH CARE

import Xyz from "xyz";

var $$Storage = {};

var StorageManager = {};

var storageManager = new Xyz({
      redis: {
        prefix: "storage:file:",
        password: "password",
        ip: "ip"
      }
    });

storageManager.Storage({
      path: "test"
    });

export {
  $$Storage ,
  StorageManager ,
  storageManager ,
}
/* storageManager Not a pure module */

Playground link: ReScript Playground


Viewing all articles
Browse latest Browse all 2592

Trending Articles