Skip to content

Instantly share code, notes, and snippets.

View azamsharp's full-sized avatar

Mohammad Azam azamsharp

View GitHub Profile
class TrackingListViewModel: ObservableObject {
@Published var trackings = [TrackingViewModel]()
func getTrackingData() {
Webservice().getCovidTrackingResult { trackingList in
if let trackingList = trackingList {
DispatchQueue.main.async {
self.trackings = trackingList.map(TrackingViewModel.init)
//
// Tracking.swift
// COVID19App
//
// Created by Mohammad Azam on 4/29/20.
// Copyright © 2020 Mohammad Azam. All rights reserved.
//
import Foundation
//
// Webservice.swift
// COVID19App
//
// Created by Mohammad Azam on 4/29/20.
// Copyright © 2020 Mohammad Azam. All rights reserved.
//
import Foundation
// CALLBACKS
// Functions that can be called back later
// Examples
// setInterval
function getMovies(moviesDownloaded) {
// HTTP REQUEST
// - HEADERS - Tell the server what we are sending and in which format
// - BODY - Tell the server about the content
let request = new XMLHttpRequest()
request.onload = function() {
console.log(this.responseText)
}
// http://www.omdbapi.com/?s=superman&apikey=564727fa
// s and apiKey are called query strings
let moviesList = document.getElementById("moviesList")
let request = new XMLHttpRequest()
// OPTION 1
// http://www.omdbapi.com/?s=superman&apikey=564727fa
// create a new XMLHTTPRequest object which will allow to make a request to the server
let request = new XMLHttpRequest()
// hook event listener for load event so I can get the data when the request is finished
request.addEventListener("load",function() {
// "this" is a XMLHttpRequest object
// console.log(this.responseText)
Given("I have following tasks") { args, userInfo in
XCUIApplication().launch()
let rows: NSArray = (userInfo?["DataTable"]) as! NSArray
let taskTextField = XCUIApplication().textFields["taskTextField"]
for index in 1...rows.count {
let taskName = (rows[index] as! NSArray)[0] as! String
let wordList = document.getElementById("wordList")
function tick() {
console.log("TICK")
}
// 1000 millisecond is 1 second
// tick is used here as a callback function
// means that it will be called back in 5 seconds
// dishList is a UL element in HTML
let dishList = document.getElementById("dishList")
// METHOD 1
/*
for(let index = 0; index < dishes.length; index++) {
let dish = dishes[index]