lemberg / obd2-swift-lib

car onboard diagnostic swift library
MIT License
143 stars 39 forks source link

Share OBD connection in multiple view controllers #10

Closed xixinjie closed 6 years ago

xixinjie commented 6 years ago

Hi @OverSwift @hellensoloviy @MaxVitruk @sergiyloza , I'd like to leverage your lib in my app. My concern is:

Do you have any suggestion?

tropicdome commented 6 years ago

Hi. I have more or less the same questions, and as follow-up would like to know

Thanks

MaxVitruk commented 6 years ago

Hello @xixinjie & @tropicdome.

Share OBD connection in multiple view controllers Run multiple OBD requests in one view controller Extend OBD commands, what if I have to support other OBD modes and pids, using swift extension? Encapsulate request and response into an object, just like obj-java-api

@xixinjie Its all about your own implementation. Single responsibility - that what a lib does. To implement shared connection you could create singleton class. Depends on your architecture solution.

Extend OBD commands - You could fork a lib to extend source code at all. Lib core works with a generics so you need just implements few interfaces to create your own command support.

Encapsulate request and response - Swift != Java :)

@tropicdome run multiple requests - You could turn repeatable for each command. If we are talking about different command - yes, you need request stack. Otherwise parser could not detect command response.

maximum number of simultaneous requests - Just one. We are storing each request in a queue.

Thanks.

xixinjie commented 6 years ago

Thank you @MaxVitruk . I'm now using singleton class to share connection. Will try other items then.