feat: create bucket service to register, deregister and store breadcrumbs
This commit is contained in:
parent
1887e34b75
commit
0ffd638d19
|
@ -0,0 +1 @@
|
|||
{{yield this.crumbs}}
|
|
@ -0,0 +1,10 @@
|
|||
import Component from '@glimmer/component';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class Breadcrumbs extends Component {
|
||||
@service bucket;
|
||||
|
||||
get crumbs() {
|
||||
return this.bucket.crumbs;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
import Service from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { schedule } from '@ember/runloop';
|
||||
|
||||
export default class BucketService extends Service {
|
||||
@tracked crumbs = [];
|
||||
|
||||
@action registerBreadcrumb(crumb) {
|
||||
schedule('actions', this, () => {
|
||||
console.log('register crumb: ', crumb);
|
||||
this.crumbs = [...this.crumbs, crumb];
|
||||
});
|
||||
}
|
||||
|
||||
@action deregisterBreadcrumb(crumb) {
|
||||
const newCrumbs = this.crumbs.filter(c => c !== crumb);
|
||||
|
||||
this.crumbs = newCrumbs;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue