dart_eval icon indicating copy to clipboard operation
dart_eval copied to clipboard

Book bridge example (not yet working)

Open BenVercammen opened this issue 1 year ago • 4 comments

@ethanblake4 Could you please have a look at this example? I've tried to reconstruct the Book bridge example from the README.md file, but get the following error:

dart_eval runtime exception: type 'List<$Value>' is not a subtype of type 'List<String>'

BenVercammen avatar Jan 06 '24 07:01 BenVercammen

Was an error with the example, will be updated in next release.

You can change the $new function in the $Book$bridge class to the following to fix:

static $Value? $new(
  Runtime runtime, $Value? target, List<$Value?> args) {
  return $Book$bridge((args[0]!.$reified as List).cast());
}

ethanblake4 avatar Jan 08 '24 20:01 ethanblake4

@ethanblake4 A new question.. I'd like to modify the list in the program, but the new pages don't show up in the bridged class. I suppose that the problem lies in my $getProperty method, but I'm not sure where to get the actual value from... Could you shed some light on this please?

BenVercammen avatar Jan 14 '24 09:01 BenVercammen

That specific use case isn't really supported with the built-in $List class currently. I created an issue to track it. You could make a custom $List wrapper that supports writeback via a type-mapper function, but if you want to do this now I'd suggest just making an addPage function or similar.

ethanblake4 avatar Jan 14 '24 22:01 ethanblake4

This is now supported in v0.7.5 using the new $List.view() constructor

ethanblake4 avatar Feb 21 '24 20:02 ethanblake4