Update handlers to resolve context refs

This commit is contained in:
Ray Miller 2025-01-06 21:44:20 +00:00
parent b463a828be
commit 12c45b628c
Signed by: ray
GPG key ID: 043F786C4CD681B8
2 changed files with 12 additions and 5 deletions

View file

@ -16,11 +16,19 @@
(description handler-description) (description handler-description)
(action handler-action)) (action handler-action))
(define* (handler description action) (define* (handler% description action)
(make-handler description action)) (make-handler description action))
(define (run-handler conn ctx handler) (define-syntax handler
(match handler (syntax-rules ()
((_ description (action arg ...))
(handler%
description
(lambda (ctx)
(action (resolve-context-refs ctx arg) ...))))))
(define (run-handler conn ctx h)
(match h
(($ <handler> description action) (($ <handler> description action)
(format #t "RUNNING HANDLER ~a~%" description) (format #t "RUNNING HANDLER ~a~%" description)
(action conn ctx)))) ((action ctx) conn))))

View file

@ -36,7 +36,6 @@
(match t (match t
(($ <task> description action register triggers) (($ <task> description action register triggers)
(format #t "RUNNING TASK ~a~%" description) (format #t "RUNNING TASK ~a~%" description)
(pk 'action action)
(let ((result ((action ctx) conn))) (let ((result ((action ctx) conn)))
(when register (when register
(register-context-var! ctx register result)) (register-context-var! ctx register result))