added example program for testing

This commit is contained in:
wisplite
2026-04-07 11:27:38 -05:00
parent aface85b80
commit 5449dc7fe9
5 changed files with 65 additions and 2 deletions
+5 -2
View File
@@ -1,6 +1,8 @@
package tether
import (
"log/slog"
"github.com/wisplite/tether/reactivity"
"gorm.io/gorm"
)
@@ -13,15 +15,16 @@ type Engine struct {
}
func NewEngine(db *gorm.DB) *Engine {
slog.SetLogLoggerLevel(slog.LevelDebug)
return &Engine{db: db, channels: make(map[string]*reactivity.Channel), mutations: make(map[string]func(ctx *MutationCtx) error), queries: make(map[string]func(ctx *QueryCtx) error)}
}
func (e *Engine) RegisterMutation(name string, mutation func(ctx *MutationCtx) error) {
e.mutations[name] = mutation
slog.Debug("Registered mutation", "name", name)
}
func (e *Engine) RegisterQuery(name string, query func(ctx *QueryCtx) error) {
e.queries[name] = query
slog.Debug("Registered query", "name", name)
}