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

Generating getter for method in record

$
0
0

Is there a option to generate getter for method in a record?

E. g., for this ReScript code:

type state = Init

type api = {state: unit => state}

let instance: api = {
  let state = ref(Init)

  {state: () => state.contents}
}

In the generated js code can we replace state instance method:

var instance = {
  state: (function () {
      return state.contents;
    })
};

with a state getter?:

var instance = {
  get state() {
    return state.contents;
  }
};

Viewing all articles
Browse latest Browse all 2592

Trending Articles