Skip to content

Instantly share code, notes, and snippets.

View GuillaumeDaviid's full-sized avatar

Guillaume DAVID GuillaumeDaviid

View GitHub Profile
const completedTasksCount = computed(() => {
const tasks = getAllTasks();
return tasks.filter(task => task.isCompleted).length;
});
decrement(): void {
this.mySignal.update(signal => signal ? signal - 1 : 0);
}
mySignal.set(3);
template: `
<p>Valeur de notre signal : {{ mySignal() }}</p>
`,
mySignal = signal(2);
import { signal } from '@angular/core';
constructor(private ref: ChangeDetectorRef) {
setInterval(() => {
this.number ++
this.ref.markForCheck();
}, 1000)
}
import { ChangeDetectionStrategy, Component} from '@angular/core';
@Component({
selector: 'app-my-component',
templateUrl: './my-component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true
})
export class MyComponent {
// votre code ...
const listMsg = countMsg > 0 ?
(msg.me.map((item, key) => <div className='chat_bot_content-msg'><h2 className='chat_bot-msg'>Moi :</h2><p className='chat_bot-msg' key={item.key}>{item}</p>
<h2 className='chat_bot-msg'>Bot :</h2> {msg.bot[key]}</div>))
: (<p></p>)
return (
<div>
<h1 className='title'>Chat Bot</h1>
<div className="chat_bot" id="chat_bot">
<div className='chat_bot_content-msg' id='chat_bot_content-msg'>
import postMessage from '../server/postMessage.js';
...
async function handleClick(e) {
e.preventDefault();
setCountMsg(countMsg + 1);
const response = await postMessage(newMsg);
setMsg({ 'me': msg.me.concat(newMsg), 'bot': msg.bot.concat(response.content[0].text) })
setNewMsg('');