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

Generating getter for method in record

$
0
0

Technically, yes

let instance = {
  let state = ref(Init)

  Object.createWithNullAndProperties({
    "state": {
      "get": () => state.contents
    }
  })
}

Though I think just using a getState function makes it much more clear that the value can change over time, in a language where we really rely on the immutability of record properties


Viewing all articles
Browse latest Browse all 2592

Trending Articles