출판사

extension Publisher
extension Publisher where Output: ThreadConfined
  • 업스트림 출판사에서 내보낸 모든 Realm 객체 및 collection을 동결합니다.

    Realm 객체를 동결하면 Realm에 쓰기가 수행될 때 더 이상 실시간 업데이트되지 않고 .threadSafeReference() 을 사용하지 않고도 스레드 간에 자유롭게 전달하는 것이 안전합니다.

    // Get a publisher for a Results
    let cancellable = myResults.publisher
       // Convert to frozen Results
       .freeze()
       // Unlike live objects, frozen objects can be sent to a concurrent queue
       .receive(on: DispatchQueue.global())
       .sink { frozenResults in
           // Do something with the frozen Results
       }
    

    선언

    스위프트

    public func freeze<T>() -> Publishers.Map<Self, T> where T : ThreadConfined, T == Self.Output

    반환 값

    업스트림 출판사가 게시하는 객체의 동결된 사본을 게시하는 출판사입니다.

  • 업스트림 발행자가 내보낸 모든 Realm 객체 변경 세트를 동결합니다.

    Realm 객체 변경 집합을 동결하면 Realm에 쓰기가 수행될 때 포함된 참고가 더 이상 실시간 업데이트되지 않으며 .threadSafeReference() 을 사용하지 않고도 스레드 간에 자유롭게 전달할 수 있습니다. 또한 변경 집합에 포함된 동결된 객체가 항상 속성 변경 사항과 일치하도록 보장하는데, 이는 스레드로부터 안전한 참고를 사용할 때 항상 그런 것은 아닙니다.

    // Get a changeset publisher for an object
    let cancellable = changesetPublisher(object)
       // Convert to frozen changesets
       .freeze()
       // Unlike live objects, frozen objects can be sent to a concurrent queue
       .receive(on: DispatchQueue.global())
       .sink { changeset in
           // Do something with the frozen changeset
       }
    

    선언

    스위프트

    public func freeze<T>() -> Publishers.Map<Self, ObjectChange<T>> where T : RealmSwiftObject, Self.Output == ObjectChange<T>

    반환 값

    업스트림 출판사가 게시하는 변경 세트의 동결된 사본을 게시하는 출판사입니다.

  • 업스트림 발행자의 모든 Realm collection 변경 세트를 동결합니다.

    Realm collection 변경 집합을 동결하면 Realm에 쓰기가 이루어질 때 포함된 참고가 더 이상 실시간 업데이트되지 않으며 .threadSafeReference() 을 사용하지 않고도 스레드 간에 자유롭게 전달되는 것을 안전합니다. 또한 변경 집합에 포함된 동결된 collection이 항상 변경 정보와 일치하도록 보장하며, 이는 스레드로부터 안전한 참고를 사용할 때 항상 그런 것은 아닙니다.

    // Get a changeset publisher for a collection
    let cancellable = myList.changesetPublisher
       // Convert to frozen changesets
       .freeze()
       // Unlike live objects, frozen objects can be sent to a concurrent queue
       .receive(on: DispatchQueue.global())
       .sink { changeset in
           // Do something with the frozen changeset
       }
    

    선언

    스위프트

    public func freeze<T: RealmCollection>()
        -> Publishers.Map<Self, RealmCollectionChange<T>> where Output == RealmCollectionChange<T>

    반환 값

    업스트림 출판사가 게시하는 변경 세트의 동결된 사본을 게시하는 출판사입니다.

  • 업스트림 발행인의 모든 Realm 섹션 결과 변경 세트를 동결합니다.

    Realm의 섹션으로 구분된 결과 변경 집합을 동결하면 Realm에 쓰기가 이루어질 때 포함된 섹션으로 구분된 결과 참고가 더 이상 실시간 업데이트되지 않으며 .threadSafeReference() 을 사용하지 않고도 스레드 간에 자유롭게 전달할 수 있습니다. 또한 변경 집합에 포함된 동결 섹션 결과가 항상 변경 정보와 일치하도록 보장하며, 이는 스레드로부터 안전한 참고를 사용할 때 항상 그런 것은 아닙니다.

    // Get a changeset publisher for the sectioned results
    let cancellable = mySectionedResults.changesetPublisher
       // Convert to frozen changesets
       .freeze()
       // Unlike live objects, frozen objects can be sent to a concurrent queue
       .receive(on: DispatchQueue.global())
       .sink { changeset in
           // Do something with the frozen changeset
       }
    

    선언

    스위프트

    public func freeze<T: RealmSectionedResult>()
        -> Publishers.Map<Self, SectionedResultsChange<T>> where Output == SectionedResultsChange<T>

    반환 값

    업스트림 출판사가 게시하는 변경 세트의 동결된 사본을 게시하는 출판사입니다.

  • 업스트림 발행자의 모든 Realm collection 변경 세트를 동결합니다.

    Realm collection 변경 집합을 동결하면 Realm에 쓰기가 이루어질 때 포함된 참고가 더 이상 실시간 업데이트되지 않으며 .threadSafeReference() 을 사용하지 않고도 스레드 간에 자유롭게 전달되는 것을 안전합니다. 또한 변경 집합에 포함된 동결된 collection이 항상 변경 정보와 일치하도록 보장하며, 이는 스레드로부터 안전한 참고를 사용할 때 항상 그런 것은 아닙니다.

    // Get a changeset publisher for a collection
    let cancellable = myMap.changesetPublisher
       // Convert to frozen changesets
       .freeze()
       // Unlike live objects, frozen objects can be sent to a concurrent queue
       .receive(on: DispatchQueue.global())
       .sink { changeset in
           // Do something with the frozen changeset
       }
    

    선언

    스위프트

    public func freeze<T: RealmKeyedCollection>()
        -> Publishers.Map<Self, RealmMapChange<T>> where Output == RealmMapChange<T>

    반환 값

    업스트림 출판사가 게시하는 변경 세트의 동결된 사본을 게시하는 출판사입니다.

  • 업스트림 출판사에서 내보낸 모든 Realm 프로젝션 변경 세트를 동결합니다.

    Realm 프로젝션 변경 집합을 동결하면 Realm에 쓰기가 수행될 때 포함된 프로젝션 참고가 더 이상 실시간 업데이트되지 않으며 .threadSafeReference() 을 사용하지 않고도 스레드 간에 자유롭게 전달할 수 있습니다. 또한 변경 집합에 포함된 동결 프로젝션이 항상 속성 변경 사항과 일치하도록 보장하며, 이는 스레드로부터 안전 참고를 사용할 때 항상 그런 것은 아닙니다.

    // Get a changeset publisher for an projection
    let cancellable = changesetPublisher(projection)
       // Convert to frozen changesets
       .freeze()
       // Unlike live projections, frozen projections can be sent to a concurrent queue
       .receive(on: DispatchQueue.global())
       .sink { changeset in
           // Do something with the frozen changeset
       }
    

    선언

    스위프트

    public func freeze<T: ProjectionObservable>()
    -> Publishers.Map<Self, ObjectChange<T>> where Output == ObjectChange<T>, T: ThreadConfined

    반환 값

    업스트림 출판사가 게시하는 변경 세트의 동결된 사본을 게시하는 출판사입니다.

결합

  • 객체 변경 집합을 다른 디스패치 대기열로 전달할 수 있습니다.

    Realm 스레드에 제한된 객체를 방출하는 출판사에서 receive(on:) 에 대한 각 호출은 .threadSafeReference() 호출로 진행해야 합니다. 반환된 출판사는 스레드에 한정된 객체를 새 대기열로 전달하는 데 필요한 로직을 처리합니다. 직렬 디스패치 대기열만 지원되며 다른 스케줄러를 사용하면 치명적인 오류가 발생합니다.

    예를 들어, 백그라운드 스레드에서 구독하려면 해당 스레드에서 몇 가지 작업을 수행한 다음 객체 변경 집합을 메인 스레드에 전달하면 됩니다.

    let cancellable = changesetPublisher(myObject)
        .subscribe(on: DispatchQueue(label: "background queue")
        .print()
        .threadSafeReference()
        .receive(on: DispatchQueue.main)
        .sink { objectChange in
            // Do things with the object on the main thread
        }
    

    선언

    스위프트

    public func threadSafeReference<T: Object>()
        -> RealmPublishers.MakeThreadSafeObjectChangeset<Self, T> where Output == ObjectChange<T>

    반환 값

    스레드에 제한된 객체에 대해 receive(on:) 를 지원하는 출판사입니다.

  • 프로젝션 변경 세트를 다른 디스패치 대기열로 전달할 수 있습니다.

    Realm 스레드에 한정된 프로젝션을 방출하는 출판사에서 receive(on:) 에 대한 각 호출은 .threadSafeReference() 호출로 진행되어야 합니다. 반환된 출판사는 스레드에 한정된 프로젝션을 새 대기열로 전달하는 데 필요한 로직을 처리합니다. 직렬 디스패치 대기열만 지원되며 다른 스케줄러를 사용하면 치명적인 오류가 발생합니다.

    예를 들어 백그라운드 스레드에서 구독하려면 해당 스레드에서 몇 가지 작업을 수행한 다음 메인 스레드에 프로젝션 변경 집합을 전달하면 됩니다.

    let cancellable = changesetPublisher(myProjection)
        .subscribe(on: DispatchQueue(label: "background queue")
        .print()
        .threadSafeReference()
        .receive(on: DispatchQueue.main)
        .sink { projectionChange in
            // Do things with the projection on the main thread
        }
    

    선언

    스위프트

    public func threadSafeReference<T: ProjectionObservable>()
    -> RealmPublishers.MakeThreadSafeObjectChangeset<Self, T> where Output == ObjectChange<T>, T: ThreadConfined

    반환 값

    스레드에 제한된 객체에 대해 receive(on:) 를 지원하는 출판사입니다.

  • Realm collection 변경 세트를 다른 디스패치 대기열로 전달할 수 있습니다.

    Realm 스레드에 제한된 객체를 방출하는 출판사에서 receive(on:) 에 대한 각 호출은 .threadSafeReference() 호출로 진행해야 합니다. 반환된 출판사는 스레드에 한정된 객체를 새 대기열로 전달하는 데 필요한 로직을 처리합니다. 직렬 디스패치 대기열만 지원되며 다른 스케줄러를 사용하면 치명적인 오류가 발생합니다.

    예를 들어 백그라운드 스레드에서 구독하려면 해당 스레드에서 몇 가지 작업을 수행한 다음 collection 변경 집합을 메인 스레드에 전달하면 됩니다.

    let cancellable = myCollection.changesetPublisher
        .subscribe(on: DispatchQueue(label: "background queue")
        .print()
        .threadSafeReference()
        .receive(on: DispatchQueue.main)
        .sink { collectionChange in
            // Do things with the collection on the main thread
        }
    

    선언

    스위프트

    public func threadSafeReference<T: RealmCollection>()
        -> RealmPublishers.MakeThreadSafeCollectionChangeset<Self, T> where Output == RealmCollectionChange<T>

    반환 값

    스레드에 제한된 객체에 대해 receive(on:) 를 지원하는 출판사입니다.

  • Realm collection 변경 세트를 다른 디스패치 대기열로 전달할 수 있습니다.

    Realm 스레드에 제한된 객체를 방출하는 출판사에서 receive(on:) 에 대한 각 호출은 .threadSafeReference() 호출로 진행해야 합니다. 반환된 출판사는 스레드에 한정된 객체를 새 대기열로 전달하는 데 필요한 로직을 처리합니다. 직렬 디스패치 대기열만 지원되며 다른 스케줄러를 사용하면 치명적인 오류가 발생합니다.

    예를 들어 백그라운드 스레드에서 구독하려면 해당 스레드에서 몇 가지 작업을 수행한 다음 collection 변경 집합을 메인 스레드에 전달하면 됩니다.

    let cancellable = myCollection.changesetPublisher
        .subscribe(on: DispatchQueue(label: "background queue")
        .print()
        .threadSafeReference()
        .receive(on: DispatchQueue.main)
        .sink { collectionChange in
            // Do things with the collection on the main thread
        }
    

    선언

    스위프트

    public func threadSafeReference<T: RealmKeyedCollection>()
        -> RealmPublishers.MakeThreadSafeKeyedCollectionChangeset<Self, T> where Output == RealmMapChange<T>

    반환 값

    스레드에 제한된 객체에 대해 receive(on:) 를 지원하는 출판사입니다.

  • Realm 섹션으로 구분된 결과 변경 세트를 다른 디스패치 대기열로 전달할 수 있습니다.

    Realm 스레드에 제한된 객체를 방출하는 출판사에서 receive(on:) 에 대한 각 호출은 .threadSafeReference() 호출로 진행해야 합니다. 반환된 출판사는 스레드에 한정된 객체를 새 대기열로 전달하는 데 필요한 로직을 처리합니다. 직렬 디스패치 대기열만 지원되며 다른 스케줄러를 사용하면 치명적인 오류가 발생합니다.

    예를 들어 백그라운드 스레드에서 구독하려면 해당 스레드에서 몇 가지 작업을 수행한 다음 collection 변경 집합을 메인 스레드에 전달하면 됩니다.

    let cancellable = mySectionedResults.changesetPublisher
        .subscribe(on: DispatchQueue(label: "background queue")
        .print()
        .threadSafeReference()
        .receive(on: DispatchQueue.main)
        .sink { sectionedResultsChange in
            // Do things with the sectioned results on the main thread
        }
    

    선언

    스위프트

    public func threadSafeReference<T: RealmSectionedResult>()
        -> RealmPublishers.MakeThreadSafeSectionedResultsChangeset<Self, T> where Output == SectionedResultsChange<T>

    반환 값

    스레드에 제한된 객체에 대해 receive(on:) 를 지원하는 출판사입니다.

Output: ThreadConfined에서 사용 가능

  • 스레드에 한정된 객체를 다른 디스패치 대기열로 전달할 수 있습니다.

    Realm 스레드에 한정된 객체를 방출하는 발행자에서 에 대한 각 호출은 에 대한 호출로 진행되어야 receive(on:) .threadSafeReference() 합니다. 반환된 발행자는 스레드에 한정된 객체를 새 대기열에 전달하는 데 필요한 로직을 처리합니다. 직렬 디스패치 대기열만 지원되며 다른 스케줄러를 사용하면 치명적인 오류가 발생합니다.

    예를 들어, 백그라운드 스레드에서 구독하려면 해당 스레드에서 몇 가지 작업을 수행한 다음 객체를 메인 스레드에 전달하면 됩니다.

    let cancellable = publisher(myObject)
        .subscribe(on: DispatchQueue(label: "background queue")
        .print()
        .threadSafeReference()
        .receive(on: DispatchQueue.main)
        .sink { object in
            // Do things with the object on the main thread
        }
    

    동결되거나 관리되지 않는 객체를 방출하는 출판사에서 이 함수를 호출하는 것은 불필요하지만 허용됩니다.

    선언

    스위프트

    public func threadSafeReference() -> RealmPublishers.MakeThreadSafe<Self>

    반환 값

    스레드에 제한된 객체에 대해 receive(on:) 를 지원하는 출판사입니다.