Skip to content

Sample app to show search request using async-await and swift-async-algorithms

License

Notifications You must be signed in to change notification settings

homerooliveira/SearchMovies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SearchMovies

Sample app to show search request using async-await and swift-async-algorithms

image

Motivation

To improve the performance of the search request, I used the throttle function of swift-async-algorithm which ensures that the minimum interval has elapsed between text update so that the app doesn't make a request for every text update. For more info see fetchAutoCompleTask in SearchViewModel.swift

Quick setup

Change the string "API_KEY" in SearchViewModel.swift to your API key of TheMovieDB.

...
private func makeURL(from text: String) -> URL? {
        var urlComponents = URLComponents()
        urlComponents.scheme = "https"
        urlComponents.host = "api.themoviedb.org"
        urlComponents.path = "/3/search/movie"
        urlComponents.queryItems = [
            .init(name: "api_key", value: "API_KEY"),
            .init(name: "query", value: text)
        ]
        
        return urlComponents.url
    }
...

For best results, run the macOS Catalyst or iOS target.

Requirements

  • macOS 12.3.0 or +
  • Xcode 13.3.0 or +

About

Sample app to show search request using async-await and swift-async-algorithms

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages