When creating the Nimbus
entrypoint we only need the baseUrl
, the remaining configurable properties will be done via function modifiers. In this topic we'll see every
configurable property, what they do and examples of how to change the default behavior.
The base url to use when dealing with relative URLs in both the frontend and the server driven views (JSONs). This should be the URL to the server that provides the server driven views.
Nimbus(baseUrl: BASE_URL) {
// hierarchy containing a navigator
}
The list of libraries containing the components, actions and operations for building the server driven views.
extension Nimbus {
func ui(_ ui: [NimbusSwiftUILibrary]) -> Nimbus
}
The application's Logger.
extension Nimbus {
func logger(_ logger: Logger) -> Nimbus
}
Example of Logger: TODO.
The application's Url builder.
extension Nimbus {
func urlBuilder(_ urlBuilder: (String) -> UrlBuilder) -> Nimbus
}
Example of URL Builder: TODO.
The application's HTTP client.
extension Nimbus {
func httpClient(_ httpClient: HttpClient) -> Nimbus
}
Example of HTTP client: TODO.
The application's View client.
extension Nimbus {
func viewClient(_ viewClient: (Core) -> ViewClient) -> Nimbus // Core contains every nimbus dependency
}
Example of View client: TODO.
The application's ID manager.
extension Nimbus {
func idManager(_ idManager: IdManager) -> Nimbus
}
Example of ID manager: TODO.
The SwiftUI view to render when a server driven view is loading. By default, it renders a spinner (ActivityIndicator
).
extension Nimbus {
func loading<LoadingView: View>(@ViewBuilder loading: @escaping () -> LoadingView) -> Nimbus
}
Example of a custom loading component: TODO.
The SwiftUI view to render when a server driven view fails to load and no fallback was provided. The error view always receive 2 arguments:
- the error itself (
Error
); - a retry function (
() -> Void
) that when called sends the request again, replacing the error component with the loading component.
By default, it renders a simple text message with a button to retry.
extension Nimbus {
func error<ErrorView: View>(@ViewBuilder error: @escaping (Error, @escaping () -> Void) -> ErrorView) -> Nimbus
}
Example of a custom error component: TODO.