Skip to content

Commit

Permalink
Add a helper method to initialise DotLottie with data
Browse files Browse the repository at this point in the history
  • Loading branch information
kirti-swiggy committed Jun 26, 2023
1 parent 598b677 commit 47a03d7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Sources/Public/DotLottie/DotLottieFileHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,21 @@ extension DotLottieFile {
}
}

/// Loads an DotLottie from a data synchronously. Returns a `Result<DotLottieFile, Error>`
/// - Parameters:
/// - data: The data(`Foundation.Data`) object to load DotLottie from
/// - filename: The name of the lottie file without the lottie extension. eg. "StarAnimation"
public static func loadedFrom(
data: Data,
filename: String)
-> Result<DotLottieFile, Error>
{
do {
let dotLottieFile = try DotLottieFile(data: data, filename: filename)
return .success(dotLottieFile)
} catch {
return .failure(error)
}
}

}

0 comments on commit 47a03d7

Please sign in to comment.