Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (err) {
console.log(`Watch error: ${err}`)
cb({ error: err })
} else {
// Update balance
const accData = await grabProviderState(fakeProvider as any)
cb(accData)
}
})
},
unsubscribe() {
// return filter.stopWatching()
},
}
const Subscription: any = createSubscription({
getCurrentValue(source: any) {
// Return the current value of the subscription (source),
// or `undefined` if the value can't be read synchronously (e.g. native Promises).
return source.currenState
},
subscribe(eventDispatcher: any, callback: any) {
// Subscribe (e.g. add an event listener) to the subscription (source).
// Call callback(newValue) whenever a subscription changes.
// Return an unsubscribe method,
// Or a no-op if unsubscribe is not supported (e.g. native Promises).
eventDispatcher.subscribe(callback)
return () => eventDispatcher.unsubscribe()
},
})
import {createSubscription} from 'create-subscription';
const Subscription = createSubscription({
getCurrentValue(sourceProp) {
// Return the current value of the subscription (sourceProp).
return sourceProp.value;
},
subscribe(sourceProp, callback) {
function handleSubscriptionChange() {
callback(sourceProp.value);
}
// Subscribe (e.g. add an event listener) to the subscription (sourceProp).
// Call callback(newValue) whenever a subscription changes.
sourceProp.subscribe(handleSubscriptionChange);
// Return an unsubscribe method.
return function unsubscribe() {
private getSubscriptionComponent() {
const SubscriptionComponent = createSubscription, T | undefined>({
getCurrentValue(_observable) {
return undefined;
},
subscribe(observable, callback) {
const subscription = observable.subscribe(callback);
return () => subscription.unsubscribe();
},
});
return SubscriptionComponent;
}
}