AsyncBox

public class AsyncBox<E: EntityInspectable & __EntityRelatable>
where E == E.EntityBindingType.EntityType

AsyncBox is a class that lets you asynchronously perform basic database write operations. Your program can just fire off these operations and forget about them, and they’ll be executed for you on a background thread, without blocking your UI or the like until writes have completed.

Important

AsyncBox does not report errors that occur in asynchronous execution.
  • Type of class this box is for.

    Declaration

    Swift

    public typealias EntityType = E
  • Create an async box for the given Box. Usually, you will want to just use Box.async to get a shared AsyncBox to place requests on.

    Declaration

    Swift

    public init(box: Box<EntityType>, enqueueTimeout: TimeInterval)
  • Queue up the given entity to be put asynchronously. If the entity hasn’t been assigned a nonzero ID yet, this will assign it a new ID. It will also return the entity’s ID. If the entity is a class, not a struct, it will also adjust the entity’s id property to match the returned ID.

    Declaration

    Swift

    @discardableResult
    public func put(_ entity: EntityType, mode: PutMode = .put) throws -> EntityId<EntityType>
  • Queue up the given entities to be put asynchronously. If an entity hasn’t been assigned a nonzero ID yet, this will assign it a new ID. It will also return all entities’ IDs. If the entity is a class, not a struct, it will also adjust each entity’s ID property to match the returned ID.

    Declaration

    Swift

    @discardableResult
    public func put<C: Collection>(_ entities: C, mode: PutMode = .put) throws -> [EntityId<EntityType>]
        where C.Element == EntityType

    Return Value

    the IDs the entities were put under, so you can e.g. assign them to your structs manually.

  • Version of put([EntityType]) that is faster because it uses ContiguousArray

    Declaration

    Swift

    @discardableResult
    public func put(_ entities: ContiguousArray<EntityType>, mode: PutMode = .put) throws
        -> ContiguousArray<EntityId<EntityType>>
  • Queue up the given entities (provided as individual parameters, not as an array) to be put asynchronously. If an entity hasn’t been assigned a nonzero ID yet, this will assign it a new ID. It will also return all entities’ IDs. If the entity is a class, not a struct, it will also adjust each entity’s ID property to match the returned ID.

    Declaration

    Swift

    @discardableResult
    public func put(_ entities: EntityType..., mode: PutMode = .put) throws -> [EntityId<EntityType>]

    Return Value

    the IDs the entities were put under, so you can e.g. assign them to your structs manually.

  • Queue up the entity with the given ID to be deleted from the database asynchronously.

    Declaration

    Swift

    public func remove(_ entityId: EntityId<EntityType>) throws
  • Queue up the entity with the given ID to be deleted from the database asynchronously.

    Declaration

    Swift

    public func remove<I>(_ entityId: I) throws where I : UntypedIdBase
  • Queue up the given entity to be deleted from the database asynchronously.

    Declaration

    Swift

    public func remove(_ entity: EntityType) throws
  • Queue up the given entities to be deleted from the database asynchronously.

    Declaration

    Swift

    public func remove<C: Collection>(_ entities: C) throws
        where C.Element == EntityType
  • Queue up the given entities (provided as individual parameters, not as an array) to be deleted from the database asynchronously.

    Declaration

    Swift

    public func remove(_ entities: EntityType...) throws
  • Queue up the entities with the given IDs to be deleted from the database asynchronously.

    Declaration

    Swift

    public func remove<C: Collection>(_ entityIDs: C) throws
        where C.Element == EntityId<EntityType>
  • Queue up the entities with the given IDs to be deleted from the database asynchronously.

    Declaration

    Swift

    public func remove<I: UntypedIdBase, C: Collection>(_ entityIDs: C) throws
        where C.Element == I
  • Queue up the entities with the given IDs (provided as individual parameters, not as an array) to be deleted from the database asynchronously.

    Declaration

    Swift

    public func remove(_ entityIDs: EntityId<EntityType>...) throws
  • Queue up the entities with the given IDs (provided as individual parameters, not as an array) to be deleted from the database asynchronously.

    Declaration

    Swift

    public func remove<I>(_ entityIDs: I...) throws where I : UntypedIdBase