@sellwild/react-native-sdk 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -83,6 +83,11 @@ class SellwildFeedViewManager : SimpleViewManager<SellwildFeedView>() {
83
83
  emit(reactContext, view, "onFeedLoaded", null)
84
84
  }
85
85
 
86
+ override fun onFeedReady(listingCount: Int) {
87
+ val payload = Arguments.createMap().apply { putInt("listingCount", listingCount) }
88
+ emit(reactContext, view, "onFeedReady", payload)
89
+ }
90
+
86
91
  override fun onError(message: String) {
87
92
  val payload = Arguments.createMap().apply { putString("message", message) }
88
93
  emit(reactContext, view, "onFeedError", payload)
@@ -132,6 +137,7 @@ class SellwildFeedViewManager : SimpleViewManager<SellwildFeedView>() {
132
137
  override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> {
133
138
  return MapBuilder.builder<String, Any>()
134
139
  .put("onFeedLoaded", MapBuilder.of("registrationName", "onFeedLoaded"))
140
+ .put("onFeedReady", MapBuilder.of("registrationName", "onFeedReady"))
135
141
  .put("onListingTap", MapBuilder.of("registrationName", "onListingTap"))
136
142
  .put("onAdImpression", MapBuilder.of("registrationName", "onAdImpression"))
137
143
  .put("onHouseAdImpression", MapBuilder.of("registrationName", "onHouseAdImpression"))
@@ -16,6 +16,7 @@ RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL)
16
16
 
17
17
  // Direct events emitted to JS callbacks.
18
18
  RCT_EXPORT_VIEW_PROPERTY(onFeedLoaded, RCTDirectEventBlock)
19
+ RCT_EXPORT_VIEW_PROPERTY(onFeedReady, RCTDirectEventBlock)
19
20
  RCT_EXPORT_VIEW_PROPERTY(onListingTap, RCTDirectEventBlock)
20
21
  RCT_EXPORT_VIEW_PROPERTY(onAdImpression, RCTDirectEventBlock)
21
22
  RCT_EXPORT_VIEW_PROPERTY(onHouseAdImpression, RCTDirectEventBlock)
@@ -45,6 +45,9 @@ final class SellwildFeedHostView: UIView, SellwildFeedViewDelegate {
45
45
  // MARK: RN events
46
46
 
47
47
  @objc var onFeedLoaded: RCTDirectEventBlock?
48
+ /// Fires after a successful fetch with the bound listing count
49
+ /// (`listingCount == 0` ⇒ empty / header-only). Reliable "ready" signal.
50
+ @objc var onFeedReady: RCTDirectEventBlock?
48
51
  @objc var onListingTap: RCTDirectEventBlock?
49
52
  @objc var onAdImpression: RCTDirectEventBlock?
50
53
  /// A house ad backfilled an empty feed slot (no-fill). Not a paid impression.
@@ -110,6 +113,10 @@ final class SellwildFeedHostView: UIView, SellwildFeedViewDelegate {
110
113
  onFeedLoaded?([:])
111
114
  }
112
115
 
116
+ func sellwildFeed(_ feed: SellwildFeedView, didBecomeReadyWithListingCount count: Int) {
117
+ onFeedReady?(["listingCount": count])
118
+ }
119
+
113
120
  func sellwildFeed(_ feed: SellwildFeedView, didTapListing listing: SellwildListing) -> Bool {
114
121
  // Forward the listing payload to JS as a plain dictionary. JS
115
122
  // can't return a value back through a direct event block, so
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellwild/react-native-sdk",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "Sellwild mobile advertising SDK for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -32,6 +32,7 @@ interface NativeFeedProps {
32
32
  scrollEnabled?: boolean
33
33
  style?: StyleProp<ViewStyle>
34
34
  onFeedLoaded?: (e: NativeSyntheticEvent<{}>) => void
35
+ onFeedReady?: (e: NativeSyntheticEvent<{ listingCount: number }>) => void
35
36
  onListingTap?: (e: NativeSyntheticEvent<{ listing: SellwildListing }>) => void
36
37
  onAdImpression?: (e: NativeSyntheticEvent<{ zoneId: string }>) => void
37
38
  onHouseAdImpression?: (e: NativeSyntheticEvent<{ zoneId: string }>) => void
@@ -84,6 +85,14 @@ export interface SellwildFeedProps {
84
85
  /** Fired once after the initial listings fetch resolves successfully. */
85
86
  onLoad?: () => void
86
87
 
88
+ /**
89
+ * Fired after a successful fetch with the number of listings bound to the
90
+ * feed. `listingCount === 0` means an empty / header-only render. Prefer this
91
+ * over `onLoad` when you need to know the feed is actually populated — `onLoad`
92
+ * also fires on an empty result.
93
+ */
94
+ onFeedReady?: (listingCount: number) => void
95
+
87
96
  /**
88
97
  * Fired when a listing card is tapped. Return `true` to consume the
89
98
  * event; return `false` (or omit) to let the SDK open `listing.url`
@@ -113,6 +122,7 @@ export function SellwildFeed({
113
122
  scrollEnabled = true,
114
123
  onContentSizeChange,
115
124
  onLoad,
125
+ onFeedReady,
116
126
  onListingTap,
117
127
  onAdImpression,
118
128
  onHouseAdImpression,
@@ -191,6 +201,9 @@ export function SellwildFeed({
191
201
  onContentSizeChange?.({ width, height })
192
202
  }}
193
203
  onFeedLoaded={() => onLoad?.()}
204
+ onFeedReady={(e: NativeSyntheticEvent<{ listingCount: number }>) => {
205
+ onFeedReady?.(e.nativeEvent.listingCount)
206
+ }}
194
207
  onListingTap={(e: NativeSyntheticEvent<{ listing: SellwildListing }>) => {
195
208
  onListingTap?.(e.nativeEvent.listing)
196
209
  }}