aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/events.ts
diff options
context:
space:
mode:
Diffstat (limited to 'contracts/events.ts')
-rw-r--r--contracts/events.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/contracts/events.ts b/contracts/events.ts
new file mode 100644
index 0000000..541bdc2
--- /dev/null
+++ b/contracts/events.ts
@@ -0,0 +1,33 @@
1/**
2 * Contract source: https://git.io/JfefG
3 *
4 * Feel free to let us know via PR, if you find something broken in this contract
5 * file.
6 */
7
8import User from 'App/Models/User';
9
10declare module '@ioc:Adonis/Core/Event' {
11 /*
12 |--------------------------------------------------------------------------
13 | Define typed events
14 |--------------------------------------------------------------------------
15 |
16 | You can define types for events inside the following interface and
17 | AdonisJS will make sure that all listeners and emit calls adheres
18 | to the defined types.
19 |
20 | For example:
21 |
22 | interface EventsList {
23 | 'new:user': UserModel
24 | }
25 |
26 | Now calling `Event.emit('new:user')` will statically ensure that passed value is
27 | an instance of the the UserModel only.
28 |
29 */
30 interface EventsList {
31 'forgot:password': { user: User; token: string };
32 }
33}