diff --git a/bind_test.go b/bind_test.go index d206db2..04e49f6 100644 --- a/bind_test.go +++ b/bind_test.go @@ -272,7 +272,7 @@ func TestBindFunc_String(t *testing.T) { testBind_Hooks(t, "foo") testBind_StringSetter(t, Bind(&mu, &val).(StringSetter)) - testBind_StringSetter(t, Bind(&mu, &val).Success(func() (err error) { return }).(StringSetter)) + testBind_StringSetter(t, Bind(&mu, &val).Success(func() {}).(StringSetter)) } func testBind_FloatSetter(t *testing.T, v FloatSetter) { @@ -291,7 +291,7 @@ func TestBindFunc_Float(t *testing.T) { testBind_Hooks(t, float64(1.23)) testBind_FloatSetter(t, Bind(&mu, &val).(FloatSetter)) - testBind_FloatSetter(t, Bind(&mu, &val).Success(func() (err error) { return }).(FloatSetter)) + testBind_FloatSetter(t, Bind(&mu, &val).Success(func() {}).(FloatSetter)) } func testBind_BoolSetter(t *testing.T, v BoolSetter) { @@ -310,7 +310,7 @@ func TestBindFunc_Bool(t *testing.T) { testBind_Hooks(t, true) testBind_BoolSetter(t, Bind(&mu, &val).(BoolSetter)) - testBind_BoolSetter(t, Bind(&mu, &val).Success(func() (err error) { return }).(BoolSetter)) + testBind_BoolSetter(t, Bind(&mu, &val).Success(func() {}).(BoolSetter)) } func testBind_TimeSetter(t *testing.T, v TimeSetter) { @@ -329,5 +329,5 @@ func TestBindFunc_Time(t *testing.T) { testBind_Hooks(t, time.Now()) testBind_TimeSetter(t, Bind(&mu, &val).(TimeSetter)) - testBind_TimeSetter(t, Bind(&mu, &val).Success(func() (err error) { return }).(TimeSetter)) + testBind_TimeSetter(t, Bind(&mu, &val).Success(func() {}).(TimeSetter)) } diff --git a/binder.go b/binder.go index 783fb43..f8f97b4 100644 --- a/binder.go +++ b/binder.go @@ -43,12 +43,18 @@ type Binder[T comparable] interface { // // The lock will be held at this point. // Do not lock or unlock the Binder within fn. Do not call JawsSet. + // + // The bind argument to the function is the previous Binder in the chain, + // and you probably want to call it's JawsSetLocked first. SetLocked(fn BindSetHook[T]) (newbind Binder[T]) // GetLocked returns a Binder[T] that will call fn instead of JawsGetLocked. // // The lock will be held at this point, preferring RLock over Lock, if available. // Do not lock or unlock the Binder within fn. Do not call JawsGet. + // + // The bind argument to the function is the previous Binder in the chain, + // and you probably want to call it's JawsGetLocked first. GetLocked(fn BindGetHook[T]) (newbind Binder[T]) // Success returns a Binder[T] that will call fn after the value has been set diff --git a/binding.go b/binding.go index aee24c2..c930826 100644 --- a/binding.go +++ b/binding.go @@ -106,6 +106,9 @@ func (bind Binding[T]) RUnlock() { // // The lock will be held at this point. // Do not lock or unlock the Binder within fn. Do not call JawsSet. +// +// The bind argument to the function is the previous Binder in the chain, +// and you probably want to call it's JawsSetLocked first. func (bind Binding[T]) SetLocked(setFn BindSetHook[T]) Binder[T] { return &BindingHook[T]{ Binder: bind, @@ -117,6 +120,9 @@ func (bind Binding[T]) SetLocked(setFn BindSetHook[T]) Binder[T] { // // The lock will be held at this point, preferring RLock over Lock, if available. // Do not lock or unlock the Binder within fn. Do not call JawsGet. +// +// The bind argument to the function is the previous Binder in the chain, +// and you probably want to call it's JawsGetLocked first. func (bind Binding[T]) GetLocked(setFn BindGetHook[T]) Binder[T] { return &BindingHook[T]{ Binder: bind, diff --git a/bindinghook.go b/bindinghook.go index c9eb854..1ce2980 100644 --- a/bindinghook.go +++ b/bindinghook.go @@ -98,6 +98,9 @@ func (bind *BindingHook[T]) JawsSetTime(elem *Element, value time.Time) error { // // The lock will be held at this point. // Do not lock or unlock the Binder within fn. Do not call JawsSet. +// +// The bind argument to the function is the previous Binder in the chain, +// and you probably want to call it's JawsSetLocked first. func (bind *BindingHook[T]) SetLocked(setFn BindSetHook[T]) Binder[T] { return &BindingHook[T]{ Binder: bind, @@ -109,6 +112,9 @@ func (bind *BindingHook[T]) SetLocked(setFn BindSetHook[T]) Binder[T] { // // The lock will be held at this point, preferring RLock over Lock, if available. // Do not lock or unlock the Binder within fn. Do not call JawsGet. +// +// The bind argument to the function is the previous Binder in the chain, +// and you probably want to call it's JawsGetLocked first. func (bind *BindingHook[T]) GetLocked(setFn BindGetHook[T]) Binder[T] { return &BindingHook[T]{ Binder: bind,