Skip to content

Conversation

@TheCodeTraveler
Copy link
Collaborator

@TheCodeTraveler TheCodeTraveler commented Oct 13, 2025

Description of Change

This PR adds the event ICameraProvider.AvailableCamerasChanged.

When IReadOnlyList<CameraInfo>? AvailableCameras in ICamera changes, ICameraProvider.AvailableCamerasChanged will fire.

This is a helpful event that allows developers to refresh their UI every time a new camera is detected as demonstrated in CameraPageViewModel:

	public CameraViewViewModel(ICameraProvider cameraProvider)
	{
		this.cameraProvider = cameraProvider;

		cameraProvider.AvailableCamerasChanged += HandleAvailableCamerasChanged;
	}

	public IReadOnlyList<CameraInfo> Cameras => cameraProvider.AvailableCameras ?? [];

	void HandleAvailableCamerasChanged(object? sender, IReadOnlyList<CameraInfo>? e)
	{
		OnPropertyChanged(nameof(Cameras));
	}

PR Checklist

Additional information

This is a small quality-of-life improvement that I discovered when refactoring the #2634

@TheCodeTraveler TheCodeTraveler added the pending documentation This feature requires documentation label Oct 13, 2025
@TheCodeTraveler
Copy link
Collaborator Author

Hey @bijington! What are your thoughts on whether we should add this to the docs?

I've added https://github.com/CommunityToolkit/Maui/issues?q=state%3Aopen%20label%3A%22pending%20documentation%22, but, when I went to open a Docs PR, I noticed that we don't have ICameraProvider documented which kinda makes sense since it's a lower-level API.

For the path forward, do you recommend we add Docs for ICameraProvider? Or is it cool to push this PR through without docs?

@TheCodeTraveler TheCodeTraveler merged commit 94e2767 into main Oct 14, 2025
11 checks passed
@TheCodeTraveler TheCodeTraveler deleted the Add-AvailableCamerasChanged-event branch October 14, 2025 20:28
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

pending documentation This feature requires documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants