Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define interface #20

Open
8 tasks
nick45chen opened this issue Mar 5, 2023 · 0 comments
Open
8 tasks

Define interface #20

nick45chen opened this issue Mar 5, 2023 · 0 comments
Assignees

Comments

@nick45chen
Copy link
Member

Initiative / goal

Defining the Fugle Real-Time SDK Interface

Description

命名可能還要再調整一下,希望能讓外部人使用上,一眼就懂 🤔

實作練習 FinanceProtocol

// 給外部使用的 Singleton
public class FugleFinance {
    public class var sharedInstance : FugleFinance {
        struct Static {
            static let instance : FugleFinance = FugleFinance()
        }
        return Static.instance
    }
}

// Http
protocol FinanceProtocol {
    
    func meta(symbol: String) async -> Result<Meta, Error>
    
    func quote(symbol: String) async -> Result<Quote, Error>
}

TODO

  • 1. 討論 FinanceProtocol

  • 1.1. 實作 FinanceProtocol

  • 2. 討論 WebsocketProtocol

  • 2.1. 實作 WebsocketProtocol

  • 3. 討論 ServiceProtocol

  • 3.1. 實作 ServiceProtocol

  • 4. 討論 Donate link

  • 4.1 setup Donate link

2. 討論 WebsocketProtocol

使用 Combine 來處理

p.s Kotlin 對應 swift Combine 的功能,應該是 Kotlin Flow ,但不太熟待研究

import Foundation

protocol WebsocketProtocol {
     // swift 還不太熟,看 documentation 應該是回傳  [Publisher](https://developer.apple.com/documentation/combine/publisher) 
}

3. 服務器狀態

import Foundation

/// 服務器狀態
protocol ServiceProtocol {
    
}

參考資料

fyi @dan12411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants