Skip to content

Commit ef0a180

Browse files
[add] Event Bus methods description
1 parent 3f53add commit ef0a180

6 files changed

Lines changed: 201 additions & 3 deletions

File tree

docs/api/api_overview.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ new booking.Booking("#root", {
3030
### Event Bus methods
3131

3232
| Name | Description |
33-
| ------------------------------------------------------- | -------------------------------------------------------------- |
34-
| [](api/internal/booking_innermethodname_method.md) | @getshort(api/internal/booking_innermethodname_method.md) |
33+
| ------------------------------------------------------- | ---------------------------------------------------------- |
34+
| [](api/internal/js_booking_exec_method.md) | @getshort(api/internal/js_booking_exec_method.md) |
35+
| [](api/internal/js_booking_intercept_method.md) | @getshort(api/internal/js_booking_intercept_method.md) |
36+
| [](api/internal/js_booking_on_method.md) | @getshort(api/internal/js_booking_on_method.md) |
37+
| [](api/internal/js_booking_setnext_method.md) | @getshort(api/internal/js_booking_setnext_method.md) |
3538

3639
### State methods
3740

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
sidebar_label: api.exec()
3+
title: exec Method
4+
description: You can learn about the exec method in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
5+
---
6+
7+
# api.exec()
8+
9+
### Description
10+
11+
@short: Allows triggering the inner events
12+
13+
### Usage
14+
15+
~~~jsx {}
16+
api.exec(
17+
event: string,
18+
config: object
19+
): void;
20+
~~~
21+
22+
### Parameters
23+
24+
- `event` - (required) an event to be fired
25+
- `config` - (required) the config object with parameters (see the event to be fired)
26+
27+
### Events
28+
29+
:::info
30+
The full list of the Booking internal events can be found [**here**](api/api_overview.md/#booking-events)
31+
:::
32+
33+
### Example
34+
35+
~~~jsx {7-17}
36+
// create Booking
37+
const booking = new booking.Booking("#root", {
38+
cards,
39+
cardShape
40+
});
41+
42+
// ...
43+
booking.api.exec("set-filter", {
44+
filterData: {
45+
date: {
46+
start: new Date(),
47+
end: new Date(2023, 4, 10),
48+
},
49+
global: "Allergist",
50+
time: [],
51+
},
52+
});
53+
~~~
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
sidebar_label: api.intercept()
3+
title: intercept Method
4+
description: You can learn about the intercept method in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
5+
---
6+
7+
# api.intercept()
8+
9+
### Description
10+
11+
@short: Allows intercepting and preventing the inner events
12+
13+
### Usage
14+
15+
~~~jsx {}
16+
api.intercept(
17+
event: string,
18+
callback: function
19+
): void;
20+
~~~
21+
22+
### Parameters
23+
24+
- `event` - (required) an event to be fired
25+
- `callback` - (required) a callback to be performed (the callback arguments will depend on the event to be fired)
26+
27+
### Events
28+
29+
:::info
30+
The full list of the Booking internal events can be found [**here**](api/api_overview.md/#booking-events)
31+
:::
32+
33+
### Example
34+
35+
~~~jsx {7-11}
36+
// create Booking
37+
const booking = new booking.Booking("#root", {
38+
cards,
39+
cardShape
40+
});
41+
42+
// every time the set-filter event is triggered, the time field will contain only the morning time
43+
booking.api.intercept("set-filter", data => {
44+
data.filterData.time = [{ start: 9, end: 12 }];
45+
return data;
46+
});
47+
~~~
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
sidebar_label: api.on() ?
3+
title: on Method
4+
description: You can learn about the on method in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
5+
---
6+
7+
# api.on()
8+
9+
### Description
10+
11+
@short: Allows attaching a handler to the inner events
12+
13+
### Usage
14+
15+
~~~jsx {}
16+
api.on(
17+
event: string,
18+
handler: function
19+
): void;
20+
~~~
21+
22+
### Parameters
23+
24+
- `event` - (required) an event to be fired
25+
- `handler` - (required) a handler to be attached (the handler arguments will depend on the event to be fired)
26+
27+
### Events
28+
29+
:::info
30+
The full list of the Booking internal events can be found [**here**](api/api_overview.md/#booking-events)
31+
:::
32+
33+
### Example
34+
35+
~~~jsx {7-8}
36+
// create Booking
37+
const booking = new booking.Booking("#root", {
38+
cards,
39+
cardShape
40+
});
41+
42+
// ...
43+
booking.api.intercept("event-name", handler);
44+
~~~
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
sidebar_label: api.setNext()
3+
title: setNext Method
4+
description: You can learn about the setNext method in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
5+
---
6+
7+
# api.setNext()
8+
9+
### Description
10+
11+
@short: Allows adding some action into the Event Bus order
12+
13+
### Usage
14+
15+
~~~jsx {}
16+
api.setNext(next: any): void;
17+
~~~
18+
19+
### Parameters
20+
21+
- `next` - (required) the action to be included into the **Event Bus** order
22+
23+
### Example
24+
25+
~~~jsx {11}
26+
const url = "https://some_backend_url";
27+
const restProvider = new booking.RestDataProvider(url);
28+
29+
Promise.all([
30+
restProvider.getCards(),
31+
]).then(([cards]) => {
32+
const booking = new booking.Booking("#root", {
33+
cards,
34+
cardShape
35+
});
36+
booking.api.setNext(restProvider);
37+
});
38+
~~~
39+
40+
:::info
41+
You need to include **RestDataProvider** into the **Event Bus** order to perform operations with data (**adding**, **deleting** etc.) and send the corresponding requests to the server
42+
:::
43+
44+
**Related articles:**
45+
- [Working with server](../../../guides/working_with_server)

sidebars.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ module.exports = {
4242
collapsible: true,
4343
collapsed: true,
4444
items: [
45-
"api/internal/booking_innermethodname_method",
45+
//"api/internal/booking_innermethodname_method",
46+
"api/internal/js_booking_exec_method",
47+
"api/internal/js_booking_intercept_method",
48+
"api/internal/js_booking_on_method",
49+
"api/internal/js_booking_setnext_method"
4650
]
4751
},
4852
{
@@ -52,6 +56,8 @@ module.exports = {
5256
collapsed: true,
5357
items: [
5458
"api/internal/booking_innermethodname_method",
59+
//"api/internal/js_kanban_getreactivestate_method",
60+
//"api/internal/js_kanban_getstate_method",
5561
]
5662
},
5763
{

0 commit comments

Comments
 (0)