You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: stories/docs/creating-a-provider.mdx
+5-8Lines changed: 5 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ To create a custom provider, we need to extend the `BaseProvider` class.
18
18
19
19
This class provides the necessary methods and properties to interact with Clover AI.
20
20
21
-
```typescript
21
+
```tsx
22
22
// my-custom-provider.tsx
23
23
import { BaseProvider } from"clover-ai";
24
24
@@ -66,11 +66,8 @@ export class MyCustomProvider extends BaseProvider {
66
66
const handleClick = () => {
67
67
this.#user_accepted=true;
68
68
69
-
// dispatch a message to Clover AI updating the provider with the new status
70
-
this.dispatch({
71
-
type: "updateProvider",
72
-
provider: this,
73
-
});
69
+
// update the Plugin state with the modified provider
70
+
this.update_plugin_provider();
74
71
};
75
72
76
73
return (
@@ -88,7 +85,7 @@ export class MyCustomProvider extends BaseProvider {
88
85
89
86
The provider class has access to the plugin's `dispatch` method, which allows it to send messages to Clover AI.
90
87
91
-
When the user clicks the button, we set `#user_accepted` to `true` and dispatch an `updateProvider` message to Clover AI with the updated provider instance.
88
+
When the user clicks the button, we set `#user_accepted` to `true` and update the plugin state with the modified provider using `this.update_plugin_provider()`.
92
89
93
90
This will trigger Clover AI to re-render the provider with the new status.
94
91
@@ -120,7 +117,7 @@ export class MyCustomProvider extends BaseProvider {
120
117
const handleClick = () => {
121
118
this.#user_accepted=true;
122
119
// update the Plugin state with the modified provider
0 commit comments