OpenFn / kit

The bits & pieces that make OpenFn work. (diagrammer, cli, compiler, runtime, runtime manager, logger, etc.)
10 stars 9 forks source link

Lazy state fails on function calls #684

Open josephjclark opened 4 months ago

josephjclark commented 4 months ago

This should work:

fn((state) => {
   state.callMeMaybe = () => {}
  return state
});

fn($.callMeMaybe())
fn((state) => {
   $.callMeMaybe()
)

But it does not - $ is undefined.

This is likely just a compiler issue. I think we should allow the usecase

josephjclark commented 4 months ago

Although to be fair I prefer this pattern anyway:

const callMeMaybe = () => {}

fn(callMeMaybe())
fn((state) => {
   callMeMaybe()
)