Detecting when a Space has been changed

I’m trying to write an add-on that appears in the Header of several spaces. I’m trying to update the UI based on the current space that is active. Using this post as an example,
https://blender.stackexchange.com/questions/135968/how-can-i-catch-a-workspace-change-event, I came up with the following code:

def notify_test(context):
    print(context.area)

handle = object()
subscribe_to = bpy.types.Context, "area"

bpy.msgbus.subscribe_rna(
    key=subscribe_to,
    owner=handle,
    args=(bpy.context,),
    notify=notify_test,
)

bpy.msgbus.publish_rna(key=subscribe_to)

context.area is None and the message event doesn’t trigger when the Context’s area is changed.

I’ve also tried:

subscribe_to = bpy.types.Space, "type"

Can anyone please help me to detect when a Space has been changed?

Thank you!

To subscribe for area changes use the key key=(bpy.types.Area, "ui_type").

To know which area changed, however, is slightly more challenging. The message bus system is very basic and doesn’t collect information about the instance whose RNA was modified, so you would need to track this yourself.

Thank you, @iceythe . I think I need to go about my add-on in another way then.