Last active
March 26, 2018 07:04
-
-
Save evianzhow/87f15ae7066994fd924c251860efb18f to your computer and use it in GitHub Desktop.
jpush-react-native with lodash throttle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const registerJPush = (alias, tags) => { | |
if (!JPushConnected) { | |
return throttledRegister(alias, tags); | |
} | |
if (alias) { | |
JPushModule.setAlias(alias, ({ errorCode = 0 }) => { | |
if (errorCode) { | |
throttledRegister(alias, null); | |
} | |
}); | |
} else { | |
JPushModule.deleteAlias(callback); | |
} | |
if (tags) { | |
JPushModule.setTags(tags, callback); | |
} else { | |
JPushModule.cleanTags(callback); | |
} | |
}; | |
const throttledRegister = throttle(registerJPush, 20 * 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment