Skip to content

Commit

Permalink
Unwrap EnvironmentAttributeKey for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Nov 21, 2024
1 parent a7cf443 commit 1c19484
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

_No unreleased changes_

## [3.0.0-pre15] - 2024-11-21

### Added
- Unwrap EnvironmentAttributeKey for logging by @TimLariviere

## [3.0.0-pre14] - 2024-11-21

### Added
Expand Down Expand Up @@ -187,7 +192,8 @@ _No unreleased changes_
### Changed
- Fabulous.XamarinForms & Fabulous.MauiControls have been moved been out of the Fabulous repository. Find them in their own repositories: [https://github.com/fabulous-dev/Fabulous.XamarinForms](https://github.com/fabulous-dev/Fabulous.XamarinForms) / [https://github.com/fabulous-dev/Fabulous.MauiControls](https://github.com/fabulous-dev/Fabulous.MauiControls)

[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre14...HEAD
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre15...HEAD
[3.0.0-pre15]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre15
[3.0.0-pre14]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre14
[3.0.0-pre13]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre13
[3.0.0-pre12]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre12
Expand Down
3 changes: 2 additions & 1 deletion src/Fabulous/Components/Environment.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ type EnvironmentExtensions =
) =
ComponentBodyBuilder<'msg, 'marker>(fun envContext treeContext context bindings ->
let envKey = value.Invoke()
let (EnvironmentAttributeKey key) = envKey.Key

// Listen to changes in the environment
context.LinkDisposable(
$"env_{envKey.Key}",
$"env_{key}",
fun () ->
envContext.ValueChanged.Subscribe(fun args ->
if args.Key = envKey.Key then
Expand Down
5 changes: 3 additions & 2 deletions src/Fabulous/Components/EnvironmentObject.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ type EnvironmentObjectExtensions =
) =
ComponentBodyBuilder<'msg, 'marker>(fun envContext treeContext context bindings ->
let envKey = value.Invoke()
let (EnvironmentAttributeKey key) = envKey.Key

// Listen to changes in the environment
context.LinkDisposable(
$"env_{envKey.Key}",
$"env_{key}",
fun () ->
envContext.ValueChanged.Subscribe(fun args ->
if args.Key = envKey.Key then
Expand All @@ -46,7 +47,7 @@ type EnvironmentObjectExtensions =
let state = envContext.Get(envKey)

// Listen to changes in the object
context.LinkDisposable($"env_{envKey.Key}_sub", fun () -> state.Changed.Subscribe(fun () -> context.NeedsRender()))
context.LinkDisposable($"env_{key}_sub", fun () -> state.Changed.Subscribe(fun () -> context.NeedsRender()))
|> ignore

(continuation state).Invoke(envContext, treeContext, context, bindings))

0 comments on commit 1c19484

Please sign in to comment.