GithubHelp home page GithubHelp logo

prg04-week6-oefening1's Introduction

PRG04 Week6 oefening1

Buggy Clock

Je ziet in game.ts dat er een klok wordt aangemaakt, en meteen weer verwijderd:

private clock:Clock;
     
constructor() {
    this.clock = new Clock();
    this.clock = undefined;
}

Echter, in de html pagina blijft de klok gewoon staan en doortellen. In de console kan je ook zien dat de klok blijft tellen.

Opdracht

  • Voeg een counter variabele toe aan clock.ts
  • Na elke seconde hoog je de counter op met 1
  • Schrijf een remove functie in clock.ts
  • Na 10 seconden roep je de remove functie aan
  • De remove functie stopt de setInterval - zie voorbeeldcode
  • De remove functie verwijdert het dom element
  • De remove functie roept de stopGame functie aan in game.ts
  • In game.ts wordt de variabele this.clock op undefined gezet

Voorbeeldcode Timer uitzetten

private timerid: number;

// aan zetten
this.timerid = setInterval(()=>this.doSomething()));
   
// uit zetten
clearInterval(this.timerid);

prg04-week6-oefening1's People

Contributors

kokodoko avatar bpikaar avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.