Skip to content

Instantly share code, notes, and snippets.

View AdamM-FC's full-sized avatar

Adam Makhfoudi AdamM-FC

  • Funding Circle
  • London
View GitHub Profile
# Loan allocation coding challenge
A requirement of the Funding Circle marketplace is to *fairly* allocate loans to investors, according to certain investor-specific criteria.
In this coding challenge you are required to write code that takes a loan as input and allocates it to an investor.
## Challenge data
**Loans** have the following attributes:
Mock Backend
Create a simple mock API using:
Simulate endpoints for:
GET /managers - Returns all managers and their assigned tasks.
POST /tasks - Adds a new task and triggers task assignment logic.
func handleError<Value>(publisher: PublisherResponse<BorrowerDetailsResponse, NetworkError>,
to keyPath: ReferenceWritableKeyPath<Self, Value>,
value: Value) {
publisher.sink(receiveCompletion: { [weak self] completion in
if case let .failure(error) = completion {
self?[keyPath: keyPath] = value
print(error)
}
}) { (response) in
typealias SubscriberResponse<CustomError: Swift.Error> = Subscribers.Completion<CustomError>
typealias CompletionHandler<CustomError: Swift.Error> = (SubscriberResponse<CustomError>) -> Void
protocol MappableViewModel: class {
associatedtype CustomError: Swift.Error
var cancellables: Set<AnyCancellable> { get set }
func bind<Value>(_ publisher: AnyPublisher<Value, Never>,
to keyPath: ReferenceWritableKeyPath<Self, Value>)
typealias PublisherResponse<Value, CustomError: Swift.Error> = Publishers.Share<Publishers.ReceiveOn<AnyPublisher<Value, CustomError>, DispatchQueue>>
protocol MappableViewModel: class {
associatedtype CustomError: Swift.Error
var cancellables: Set<AnyCancellable> { get set }
func bind<Value>(_ publisher: AnyPublisher<Value, Never>,
to keyPath: ReferenceWritableKeyPath<Self, Value>)
func createPropertyPublisher<Value>(publisher: PublisherResponse<Value, CustomError>) -> AnyPublisher<Value, Never>
}
protocol MappableViewModel: class {
var cancellables: Set<AnyCancellable> { get set }
func bind<Value>(_ publisher: AnyPublisher<Value, Never>,
to keyPath: ReferenceWritableKeyPath<Self, Value>)
}
extension MappableViewModel {
func bind<Value>(_ publisher: AnyPublisher<Value, Never>,
to keyPath: ReferenceWritableKeyPath<Self, Value>) {