@@ -179,13 +179,20 @@ export class ToastController {
179
179
180
180
// default global inject key to fetch the controller
181
181
const injectkey = Symbol ( )
182
+ const fetchKey = Symbol ( )
183
+
182
184
const rootkey = 'root' // TODO: I guess this variable is not used in any place...
183
185
184
186
const defaults = {
185
187
container : undefined ,
186
188
toasts : [ ] ,
187
189
root : false ,
188
190
}
191
+
192
+ export function getKey ( ) : any {
193
+ return inject ( fetchKey )
194
+ }
195
+
189
196
export function useToast ( ) : ToastInstance | undefined
190
197
export function useToast ( vm : { id : symbol } , key ?: symbol ) : ToastInstance | undefined
191
198
export function useToast (
@@ -195,7 +202,7 @@ export function useToast(
195
202
196
203
export function useToast ( vm ?: any , key : symbol = injectkey ) : ToastInstance | undefined {
197
204
//let's get our controller to fetch the toast instance
198
- const controller = inject ( key !== null ? key : injectkey ) as ToastController
205
+ const controller = inject ( getKey ( ) ) as ToastController
199
206
200
207
// not parameters passed, use root if defined
201
208
if ( ! vm ) {
@@ -211,6 +218,7 @@ export function useToast(vm?: any, key: symbol = injectkey): ToastInstance | und
211
218
212
219
export const BToastPlugin : Plugin = {
213
220
install : ( app : App , options : BootstrapVueOptions = { } ) => {
221
+ app . provide ( fetchKey , options ?. BToast ?. injectkey ?? injectkey )
214
222
app . provide ( options ?. BToast ?. injectkey ?? injectkey , new ToastController ( ) )
215
223
} ,
216
224
}
0 commit comments