interface.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { Observer, Subject, Subscribable, Unsubscribable } from "rxjs"
  2. /* --------------------------------------------
  3. Fis actor to declare its own subscribable but extended from RXJS
  4. */
  5. interface ActorService { }
  6. /* Stateful actor service to be instantiated by concrete class.
  7. To add in behaviour and model state repository */
  8. interface ActorContext { }
  9. /* references to associate actors */
  10. // Please note members of an interface are ALWAYS PUBLIC.
  11. interface FisActor<T> extends Subscribable<T> {
  12. actorId: String
  13. actorName: String
  14. actorContext: ActorContext
  15. incomingBus: Subscribable<T>
  16. outgoingBus: Subscribable<T>
  17. actorService: ActorService
  18. }
  19. export abstract class FisActorBaseImpl<T> implements FisActor<T> {
  20. actorId!: String
  21. actorName!: String
  22. incomingBus!: Subscribable<T>
  23. outgoingBus!: Subscribable<T>
  24. actorService!: ActorService
  25. actorContext!: Object
  26. constructor(actorContext: ActorContext) {
  27. // logic here
  28. }
  29. subscribe(observer: Partial<Observer<T>>): Unsubscribable {
  30. throw new Error("Method to be defined....")
  31. }
  32. }
  33. interface Actor<T> extends Subscribable<T> {
  34. actorId: String
  35. actorName: String
  36. actorStream: Subscribable<T>
  37. }
  38. abstract class Sample<T> implements Actor<T> {
  39. actorId!: String
  40. actorName!: String
  41. actorStream!: Subscribable<T>
  42. subscribe(observer: Partial<Observer<T>>): Unsubscribable {
  43. throw new Error("Method not implemented.")
  44. }
  45. }