demo_frontend
Version:
Internet Computer starter application
56 lines (44 loc) • 1.01 kB
JavaScript
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { actor } from 'ember-cli-dfinity';
export default class DemoHelloComponent extends Component {
name;
valid;
submitting;
greeting;
// Bind to the hello actor deployed to the hello_backend canister using the default agent.
({ canister: 'demo_backend' })
hello;
snackbar;
validity (valid) {
this.valid = valid;
}
async submit () {
try {
this.submitting = true;
this.greeting = await this.hello.greet(this.name);
}
catch (err) {
this.snackbar.showError (err);
}
finally {
this.submitting = false;
}
}
reset () {
this.submitting = false;
this.name = null;
}
get isSubmitButtonDisabled () {
return !this.valid || this.submitting;
}
}