Skip to content

Commit

Permalink
improve Reorder example (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
muir authored Apr 18, 2022
1 parent eb16c23 commit 7bd001e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions example_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,30 @@ func ExampleNonFinal() {
// This demonstrates how it to have a default that gets overridden by
// by later inputs.
func ExampleReorder() {
type string2 string
seq1 := nject.Sequence("example",
nject.Shun(func() string {
fmt.Println("fallback default included")
return "fallback default"
}),
func(s string) string2 {
return "<" + string2(s) + ">"
},
)
seq2 := nject.Sequence("later inputs",
// for this to work, it must be reordered to be in front
// of the string->string2 provider
nject.Reorder(func() string {
return "override value"
}),
)
fmt.Println(nject.Run("combination",
seq1,
seq2,
func(s string) {
func(s string2) {
fmt.Println(s)
},
))
// Output: override value
// Output: <override value>
// <nil>
}

0 comments on commit 7bd001e

Please sign in to comment.