Refactor handling of ContextServer notifications

The notification handler registration is now more explicit, with
handlers set up before server initialization to avoid potential race
conditions.
This commit is contained in:
Ben Brandt 2025-07-30 15:48:40 +02:00
parent f028ca4d1a
commit 81c111510f
No known key found for this signature in database
GPG key ID: D4618C5D3B500571
4 changed files with 79 additions and 56 deletions

View file

@ -115,10 +115,11 @@ impl InitializedContextServerProtocol {
self.inner.notify(T::METHOD, params)
}
pub fn on_notification<F>(&self, method: &'static str, f: F)
where
F: 'static + Send + FnMut(Value, AsyncApp),
{
pub fn on_notification(
&self,
method: &'static str,
f: Box<dyn 'static + Send + FnMut(Value, AsyncApp)>,
) {
self.inner.on_notification(method, f);
}
}