 import Result
 import Box
 
+public enum PlaylistEvent {
+    case Load(index: Int)
+    case ChangePlayState(index: Int, playerState: PlayerState)
+}
+
 public class Playlist: Equatable, Hashable {
     public   let id:           String
     public   var title:        String
     public   var tracks:       [Track]
     public   var thumbnailUrl: NSURL? { return tracks.first?.thumbnailUrl }
-    public   var signal:       Signal<Int, NSError>
-    internal var sink:         SinkOf<ReactiveCocoa.Event<Int, NSError>>
+    public   var signal:       Signal<PlaylistEvent, NSError>
+    internal var sink:         SinkOf<ReactiveCocoa.Event<PlaylistEvent, NSError>>
 
     static var playlistNumberLimit: Int { return 5 }
     static var trackNumberLimit:    Int { return 5 }

        id     = json["url"].stringValue
        title  = json["title"].stringValue
        tracks = json["tracks"].arrayValue.map({ Track(json: $0) })
        let pipe    = Signal<Int, NSError>.pipe()
        self.signal = pipe.0
        self.sink   = pipe.1
    }

        for trackStore in store.tracks {
            tracks.append(Track(store:trackStore as! TrackStore))
        }
        let pipe    = Signal<PlaylistEvent, NSError>.pipe()
        self.signal = pipe.0
        self.sink   = pipe.1
    }
