Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-eventbus
Commits
2341c42d
Unverified
Commit
2341c42d
authored
Jun 19, 2019
by
Łukasz Magiera
Committed by
GitHub
Jun 19, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3 from libp2p/feat/interface
generify options.
parents
04b7ec33
2ea3b26f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
interface.go
interface.go
+5
-3
No files found.
interface.go
View file @
2341c42d
...
...
@@ -10,7 +10,8 @@ var closeEmit struct{}
type
subSettings
struct
{
forcedType
reflect
.
Type
}
type
SubOption
func
(
*
subSettings
)
error
type
SubOption
func
(
interface
{})
error
// ForceSubType is a Subscribe option which overrides the type to which
// the subscription will be done. Note that the evtType must be assignable
...
...
@@ -29,7 +30,8 @@ type SubOption func(*subSettings) error
// cancel, err := eventbus.Subscribe(eventCh, event.ForceSubType(new(Event)))
// [...]
func
ForceSubType
(
evtType
interface
{})
SubOption
{
return
func
(
s
*
subSettings
)
error
{
return
func
(
settings
interface
{})
error
{
s
:=
settings
.
(
*
subSettings
)
typ
:=
reflect
.
TypeOf
(
evtType
)
if
typ
.
Kind
()
!=
reflect
.
Ptr
{
return
errors
.
New
(
"ForceSubType called with non-pointer type"
)
...
...
@@ -42,7 +44,7 @@ func ForceSubType(evtType interface{}) SubOption {
type
emitterSettings
struct
{
makeStateful
bool
}
type
EmitterOption
func
(
*
emitterSettings
)
type
EmitterOption
func
(
interface
{})
error
// Stateful is an Emitter option which makes makes the eventbus channel
// 'remember' last event sent, and when a new subscriber joins the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment