12345678910111213141516171819202122232425262728293031 |
- package api
- type BehaviorSubjectStruct struct {
- Subscriber
- initial interface{}
- }
- func BehaviorSubject(initial ...interface{}) *BehaviorSubjectStruct {
- var (
- value interface{}
- )
- if len(initial) > 0 {
- value = initial[0]
- }
- return &BehaviorSubjectStruct{
- initial: value,
- Subscriber: *NewSubscriber(),
- }
- }
- func (behavior *BehaviorSubjectStruct) Subscribe(handles ...func(...interface{})) (subscription *Subscription) {
- subscription = behavior.Subscriber.Subscribe(handles...)
- if behavior.initial != nil {
- subscription.Next(behavior.initial)
- }
- return
- }
|