|
| 1 | +import { PipeMessage } from "./message"; |
| 2 | + |
| 3 | +/** |
| 4 | + * Pipe Fitting Interface. |
| 5 | + * |
| 6 | + * An `IPipeFitting<` can be connected to other |
| 7 | + * `IPipeFitting`s, forming a Pipeline. |
| 8 | + * `Messages`s are written to one end of a |
| 9 | + * Pipeline by some client code. The messages are then |
| 10 | + * transferred in synchronous fashion from one fitting to |
| 11 | + * the next. |
| 12 | + */ |
| 13 | +export interface IPipeFitting { |
| 14 | + /** |
| 15 | + * Connect another Pipe Fitting to the output. |
| 16 | + *` |
| 17 | + * Fittings connect and write to |
| 18 | + * other fittings in a one way synchronous |
| 19 | + * chain, as water typically flows one direction |
| 20 | + * through a physical pipes.ts.` |
| 21 | + * |
| 22 | + * @return Boolean true if no other fitting was already connected. |
| 23 | + */ |
| 24 | + connect(output: IPipeFitting): boolean; |
| 25 | + |
| 26 | + /** |
| 27 | + * Disconnect the Pipe Fitting connected to the output. |
| 28 | + *` |
| 29 | + * This disconnects the output fitting, returning a |
| 30 | + * reference to it. If you were splicing another fitting |
| 31 | + * into a pipeline, you need to keep (at least briefly) |
| 32 | + * a reference to both sides of the pipeline in order to |
| 33 | + * connect them to the input and output of whatever |
| 34 | + * fitting that you're splicing in.` |
| 35 | + * |
| 36 | + * @return IPipeFitting the now disconnected output fitting |
| 37 | + */ |
| 38 | + disconnect(): IPipeFitting | null; |
| 39 | + |
| 40 | + /** |
| 41 | + * Write the message to the output Pipe Fitting. |
| 42 | + *` |
| 43 | + * There may be subsequent filters and tees |
| 44 | + * (which also implement this interface), that the |
| 45 | + * fitting is writing to, and so a message |
| 46 | + * may branch and arrive in different forms at |
| 47 | + * different endpoints. ` |
| 48 | + *` |
| 49 | + * If any fitting in the chain returns false |
| 50 | + * from this method, then the client who originally |
| 51 | + * wrote into the pipes.ts can take action, such as |
| 52 | + * rolling back changes.` |
| 53 | + */ |
| 54 | + write(message: PipeMessage): boolean; |
| 55 | +} |
| 56 | + |
| 57 | +/** |
| 58 | + * Pipe Aware interface. |
| 59 | + * |
| 60 | + * Can be implemented by any PureMVC Core that wishes |
| 61 | + * to communicate with other Cores using the Pipes |
| 62 | + * utility. |
| 63 | + */ |
| 64 | +export interface IPipeAware { |
| 65 | + acceptInputPipe(name: string, pipe: IPipeFitting): void; |
| 66 | + acceptOutputPipe(name: string, pipe: IPipeFitting): void; |
| 67 | +} |
0 commit comments