question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add isOfType helper

See original GitHub issue

Use case - a redux saga that is run when two actions dispatched, one with payload, other w/o payload

const fetchEntity = createActionCreator('FETCH', resolve => (id: string) => resolve(id));
const reFetchEntity = createActionCreator('RE_FETCH')

function* watchFetchEntity() {
  yield takeLastest([getType(fetchEntity), getType(reFetchEntity)], fetchEntitySaga);
}

function* fetchEntitySaga(action: ActionType<typeof fetchEntity> | ActionType<typeof reFetchEntity>) {
  const id = isOfType(getType(fetchEntity), action) 
    ? action.payload // id from fetchEntity
    : yield select(selectEntityId)
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
the-dr-lazycommented, Dec 7, 2019

This feature will release in version 3.1.0. Thanks to @kotarella1110 and @nikolay-borzov.

0reactions
the-dr-lazycommented, Dec 8, 2019

🎉 This issue has been resolved in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Instantiate objects using a helper class - Stack Overflow
The problem I have is that i can create an instance of the car object such as, Car car1 = new car("Audi","A4","BF10YMR"); however...
Read more >
Documentation - Advanced Types - TypeScript
This page lists some of the more advanced ways in which you can model types, it works in tandem with the Utility Types...
Read more >
Error when try to create and array: The 'from' property value in ...
Solved: Hi, I try to create an array but I get an error: The 'from' property value in the 'table' action inputs is...
Read more >
Typesafe utilities for "action-creators" in Redux / Flux ... - GitHub
We have an equivalent helper ( isOfType ) which accept type-constants as parameter providing the same functionality. // epics.ts import { isOfType }...
Read more >
ATL/User Guide - The ATL Language - Eclipsepedia
The thisModule variable makes it possible to access the helpers and ... a copy of self with the element o added at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found