Mercurial > public > lazybear
comparison LazyBear/Views/Home/HomeView.swift @ 399:5c99883c7964
Implementing networking in CompanyView
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sat, 15 May 2021 12:31:40 +0200 |
parents | 6303385b3629 |
children | f843c6382529 |
comparison
equal
deleted
inserted
replaced
398:933546fa5651 | 399:5c99883c7964 |
---|---|
48 if let latestCurrencies = home.data.latestCurrencies { | 48 if let latestCurrencies = home.data.latestCurrencies { |
49 CurrencyRow(latestCurrencies: latestCurrencies) | 49 CurrencyRow(latestCurrencies: latestCurrencies) |
50 .listRowInsets(EdgeInsets()) | 50 .listRowInsets(EdgeInsets()) |
51 } | 51 } |
52 } | 52 } |
53 .onReceive(timer) { _ in home.request("https://api.lazybear.app/home/type=streaming", isInitRequest: false) } | 53 .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } // Start timer |
54 .onReceive(timer) { _ in home.request("https://api.lazybear.app/home/type=streaming", isInitRequest: false) } // Receive timer notification | |
54 .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer | 55 .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer |
55 .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") | 56 .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") |
56 .navigationBarTitleDisplayMode(.inline) | 57 .navigationBarTitleDisplayMode(.inline) |
57 .navigationViewStyle(StackNavigationViewStyle()) | 58 .navigationViewStyle(StackNavigationViewStyle()) |
58 .toolbar { | 59 .toolbar { |
70 } | 71 } |
71 } else { | 72 } else { |
72 ProgressView() | 73 ProgressView() |
73 .onAppear { | 74 .onAppear { |
74 home.request("https://api.lazybear.app/home/type=init", isInitRequest: true) | 75 home.request("https://api.lazybear.app/home/type=init", isInitRequest: true) |
75 | |
76 // Restart timer | |
77 self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() | |
78 } | 76 } |
79 | 77 |
80 } | 78 } |
81 } | 79 } |
82 } | 80 } |