unregister removes the callback associated with id, if any. It is kept for API symmetry with register so future callers (e.g. dynamic hook owners that need to detach before client Close) do not have to reinvent it. nolint:unused // kept for API symmetry with register; see comment above.
(id string)
| 274 | // |
| 275 | //nolint:unused // kept for API symmetry with register; see comment above. |
| 276 | func (h *onCloseHooks) unregister(id string) { |
| 277 | h.mu.Lock() |
| 278 | defer h.mu.Unlock() |
| 279 | if _, exists := h.hooks[id]; !exists { |
| 280 | return |
| 281 | } |
| 282 | delete(h.hooks, id) |
| 283 | for i, x := range h.order { |
| 284 | if x == id { |
| 285 | h.order = append(h.order[:i], h.order[i+1:]...) |
| 286 | break |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | // run invokes all registered callbacks in registration order and returns |
| 292 | // the first non-nil error encountered. All callbacks are executed even if |
no outgoing calls