IGListKit/Source/IGListDiffKit/IGListMacros.h
Maxime Ollivier ad5171978e create IGListUpdatingDelegateExperimental
Summary:
For diffing, `IGListAdapterUpdater` uses the full `fromObjects` instead of `validObjects`, which can be different if we're missing `IGListSectionController`. The diffing results won't match what the `IGListAdapter` tells the `UICollectionView`, so we can crash.

To fix this, lets try to generate the `IGListSectionController` before performing the diffing, and keep them in a container object (`IGListTransitionData`) alonside the `fromObjects` and `toObjects`. This might also unblock other cool features in the future, like giving `IGListSectionControllers` time for background work, but that's for another day.

Since this change is relatively large, lets create a temporary protocol `IGListUpdatingDelegateExperimental` which will have a slightly different API from `IGListUpdatingDelegate`. When/if the new implementation ships, we can merge both protocols.

Why not edit `IGListAdapterUpdater` directly?
* I don't want to mess up exiting updaters just yet.

Reviewed By: patters

Differential Revision: D23145776

fbshipit-source-id: 21642cafa64e2a26a173e2ba683ef5c6cede17d7
2020-09-08 09:11:11 -07:00

36 lines
1.2 KiB
C

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#ifndef IGLK_SUBCLASSING_RESTRICTED
#if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted)
#define IGLK_SUBCLASSING_RESTRICTED __attribute__((objc_subclassing_restricted))
#else
#define IGLK_SUBCLASSING_RESTRICTED
#endif // #if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted)
#endif // #ifndef IGLK_SUBCLASSING_RESTRICTED
#ifndef IGLK_UNAVAILABLE
#define IGLK_UNAVAILABLE(message) __attribute__((unavailable(message)))
#endif // #ifndef IGLK_UNAVAILABLE
#if defined(IGLK_LOGGING_ENABLED) && IGLK_LOGGING_ENABLED
#define IGLKLog( s, ... ) do { NSLog( @"IGListKit: %@", [NSString stringWithFormat: (s), ##__VA_ARGS__] ); } while(0)
#else
#define IGLKLog( s, ... )
#endif
#ifndef IGLK_DEBUG_DESCRIPTION_ENABLED
#define IGLK_DEBUG_DESCRIPTION_ENABLED DEBUG
#endif // #ifndef IGLK_DEBUG_DESCRIPTION_ENABLED
#define IGLK_BLOCK_CALL_SAFE(BLOCK, ...) \
do { \
__typeof(BLOCK) ig_safe_block = (BLOCK); \
if (ig_safe_block) { \
ig_safe_block(__VA_ARGS__); \
} \
} while (NO)