fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming
https://fabulous.dev
Apache License 2.0
1.15k stars 122 forks source link

Update documentation for extensions to include new parameter #799

Closed franko-franicevich closed 3 years ago

franko-franicevich commented 4 years ago

Hey all, we're trying to update to the 0.57 release of fabulous, and have struck the problem that all of our view extensions no longer compile due to a change to the extension API.

The examples on https://fsprojects.github.io/Fabulous/Fabulous.XamarinForms/views-extending.html are for the old style extensions that we're using, and no longer work either.

Specifically, there seems to have been a new undocumented parameter added to the ViewElement.Create<ABC>(create, update, attribs) and ViewBuilders.UpdateBASE (prev, source, target) functions. There may be other changes we're not aware of.

All the existing extensions in the code itself have been moved to the new (undocumented) codegen system, so I can't just look to those to see how things have changed :D

Short of getting the full documentation and examples updated, is there a quick fix we can use in our extensions? (that is, what's the new, missing parameter, and how do we construct it)

thanks in advance.

TimLariviere commented 4 years ago

Hi @franko-franicevich Sorry about that, still haven't gotten around writing the documentation for codegen and forgot to document that new parameter.

If you want, you can still take a look at FabulousContacts which uses the old style for the extensions with the new parameter. https://github.com/TimLariviere/FabulousContacts/blob/88115288df869c96b09e9890e38302b5c4d923a1/FabulousContacts/Controls/BorderedEntry.fs#L36-L38

Normally only this new registry parameter has changed since last time. It is here because we needed to handle attached properties differently internally.

It is created internally by Fabulous, so you just need to pass it around.

// The incremental update method
let update registry (prev: ViewElement voption) (source: ViewElement) (target: ABC) =
    ViewBuilders.UpdateBASE (registry, prev, source, target)
franko-franicevich commented 4 years ago

Thanks so much for your fast response on this, @TimLariviere .

These changes were easy, and have done the trick - We've updated now and are running again.

(and, unrelated, but thanks also for the new 'key' field changes to prevent unwanted re-use of controls. We had a lot of ugly code to work around that for one specific case that we can now delete after we implement support.)

franko-franicevich commented 4 years ago

I'll not close this issue, as I'm sure others will(maybe?) strike this until the docs are fixed, but for now, my problem is resolved.