2023-04-08 11:20:34 +02:00
|
|
|
package resource
|
|
|
|
|
|
|
|
import (
|
2023-04-14 10:59:37 +02:00
|
|
|
"git.defalsify.org/vise/state"
|
2023-04-08 11:20:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type StateResource struct {
|
|
|
|
Resource
|
|
|
|
st *state.State
|
|
|
|
}
|
|
|
|
|
|
|
|
func ToStateResource(rs Resource) *StateResource {
|
|
|
|
return &StateResource{rs, nil}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewStateResource(st *state.State) *StateResource {
|
|
|
|
return &StateResource {
|
|
|
|
NewMenuResource(),
|
|
|
|
st,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-08 12:31:05 +02:00
|
|
|
func(sr *StateResource) WithState(st *state.State) *StateResource {
|
|
|
|
if sr.st != nil {
|
2023-04-08 11:20:34 +02:00
|
|
|
panic("state already set")
|
|
|
|
}
|
2023-04-08 12:31:05 +02:00
|
|
|
sr.st = st
|
|
|
|
return sr
|
|
|
|
}
|