MCPcopy
hub / github.com/duke-git/lancet / ExampleAll

Function ExampleAll

promise/promise_example_test.go:121–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119}
120
121func ExampleAll() {
122 p1 := New(func(resolve func(string), reject func(error)) {
123 resolve("a")
124 })
125 p2 := New(func(resolve func(string), reject func(error)) {
126 resolve("b")
127 })
128 p3 := New(func(resolve func(string), reject func(error)) {
129 resolve("c")
130 })
131
132 pms := []*Promise[string]{p1, p2, p3}
133 p := All(pms)
134
135 result, err := p.Await()
136 if err != nil {
137 return
138 }
139
140 fmt.Println(result)
141
142 // Output:
143 // [a b c]
144}
145
146func ExampleAny() {
147 p1 := New(func(resolve func(string), reject func(error)) {

Callers

nothing calls this directly

Calls 3

AllFunction · 0.85
AwaitMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…