File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 11namespace Fabulous
22
3+ open System
34open System.Runtime .CompilerServices
45
56[<Struct; NoEquality; NoComparison>]
@@ -88,6 +89,20 @@ module MvuComponent =
8889
8990 let Data =
9091 Attributes.defineSimpleScalar< MvuComponentData> " MvuComponent_Data" ScalarAttributeComparers.noCompare ( fun _ _ _ -> ())
92+
93+ let canReuseMvuComponent ( prev : Widget ) ( curr : Widget ) =
94+ let prevData =
95+ match prev.ScalarAttributes with
96+ | ValueSome attrs when attrs.Length > 0 -> attrs[ 0 ]. Value :?> MvuComponentData
97+ | _ -> failwith " Component widget must have a body"
98+
99+ let currData =
100+ match curr.ScalarAttributes with
101+ | ValueSome attrs when attrs.Length > 0 -> attrs[ 0 ]. Value :?> MvuComponentData
102+ | _ -> failwith " Component widget must have a body"
103+
104+ // NOTE: Somehow using = here crashes the app and prevents debugging...
105+ Object.Equals( prevData.Arg, currData.Arg)
91106
92107/// Delegate used by the MvuComponentBuilder to compose a component body
93108/// It will be aggressively inlined by the compiler leaving no overhead, only a pure function that returns a WidgetBuilder
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ module ViewHelpers =
88 false
99 else if ( prevKey = Memo.MemoWidgetKey) then
1010 Memo.canReuseMemoizedWidget prevWidget currWidget
11+ else if ( prevKey = MvuComponent.WidgetKey) then
12+ MvuComponent.canReuseMvuComponent prevWidget currWidget
1113 else
1214 true
1315
You can’t perform that action at this time.
0 commit comments