mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-06 21:52:28 +08:00
Merge branch 'main' into v2
This commit is contained in:
@@ -145,14 +145,6 @@ func unsafeInvokeFunc(fn any, args ...any) []reflect.Value {
|
||||
return fv.Call(params)
|
||||
}
|
||||
|
||||
func functionValue(function any) reflect.Value {
|
||||
v := reflect.ValueOf(function)
|
||||
if v.Kind() != reflect.Func {
|
||||
panic(fmt.Sprintf("Invalid function type, value of type %T", function))
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func mustBeFunction(function any) {
|
||||
v := reflect.ValueOf(function)
|
||||
if v.Kind() != reflect.Func {
|
||||
|
||||
@@ -108,21 +108,21 @@ func ExampleDebounced() {
|
||||
}
|
||||
|
||||
func ExampleSchedule() {
|
||||
var result []string
|
||||
count := 0
|
||||
|
||||
appendFn := func(s string) {
|
||||
result = append(result, s)
|
||||
increase := func() {
|
||||
count++
|
||||
}
|
||||
|
||||
stop := Schedule(1*time.Second, appendFn, "*")
|
||||
stop := Schedule(1*time.Second, increase)
|
||||
|
||||
time.Sleep(3 * time.Second)
|
||||
close(stop)
|
||||
|
||||
fmt.Println(result)
|
||||
fmt.Println(count)
|
||||
|
||||
// Output:
|
||||
// [* * *]
|
||||
// 3
|
||||
}
|
||||
|
||||
func ExamplePipeline() {
|
||||
|
||||
Reference in New Issue
Block a user