File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -355,3 +355,26 @@ module Attributes =
355355 |> AttributeDefinitionStore.registerScalar
356356
357357 { Key = key; Name = name }
358+
359+ let inline defineEventNoDispatch < 'args >
360+ name
361+ ( [<InlineIfLambda>] getEvent : obj -> IEvent < EventHandler < 'args >, 'args >)
362+ : SimpleScalarAttributeDefinition < 'args -> unit > =
363+ let key =
364+ SimpleScalarAttributeDefinition.CreateAttributeData(
365+ ScalarAttributeComparers.noCompare,
366+ ( fun _ ( newValueOpt : ( 'args -> unit) voption) node ->
367+ match node.TryGetHandler( name) with
368+ | ValueNone -> ()
369+ | ValueSome handler -> handler.Dispose()
370+
371+ match newValueOpt with
372+ | ValueNone -> node.RemoveHandler( name)
373+ | ValueSome( fn) ->
374+ let event = getEvent node.Target
375+ node.SetHandler( name, event.Subscribe( fun args -> fn args)))
376+ )
377+
378+ |> AttributeDefinitionStore.registerScalar
379+
380+ { Key = key; Name = name }
You can’t perform that action at this time.
0 commit comments