From 7b7da4bc137d04d6e92aacba342cb6fbfa96f875 Mon Sep 17 00:00:00 2001
From: Michael Kirk <michael@signal.org>
Date: Wed, 12 Sep 2018 10:05:47 -0500
Subject: [PATCH] add docs to BlockListCache

---
 SignalMessaging/utils/BlockListCache.swift | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/SignalMessaging/utils/BlockListCache.swift b/SignalMessaging/utils/BlockListCache.swift
index 0e24b9d61..ebc103179 100644
--- a/SignalMessaging/utils/BlockListCache.swift
+++ b/SignalMessaging/utils/BlockListCache.swift
@@ -9,6 +9,30 @@ public protocol BlockListCacheDelegate: class {
     func blockListCacheDidUpdate(_ blocklistCache: BlockListCache)
 }
 
+/// A performant cache for which contacts/groups are blocked.
+///
+/// The source of truth for which contacts and groups are blocked is the `blockingManager`, but because
+/// those accessors are made to be thread safe, they can be slow in tight loops, e.g. when rendering table
+/// view cells.
+///
+/// Typically you'll want to create a Cache, update it to the latest state while simultaneously being informed
+/// of any future changes to block list state.
+///
+///     class SomeViewController: BlockListCacheDelegate {
+///         let blockListCache = BlockListCache()
+///         func viewDidLoad() {
+///            super.viewDidLoad()
+///            blockListCache.startObservingAndSyncState(delegate: self)
+///            self.updateAnyViewsWhichDepondOnBlockListCache()
+///         }
+///
+///         func blockListCacheDidUpdate(_ blocklistCache: BlockListCache) {
+///             self.updateAnyViewsWhichDepondOnBlockListCache()
+///         }
+///
+///         ...
+///      }
+///
 @objc(OWSBlockListCache)
 public class BlockListCache: NSObject {