在redux-thunk中,我们可以定义#version 330
in vec4 v_clip_pos;
out vec4 color;
void main() {
vec3 ndc_pos = v_clip_pos.xyz / v_clip_pos.w;
vec3 dx = dFdx( ndc_pos );
vec3 dy = dFdy( ndc_pos );
vec3 N = normalize(cross(dx, dy));
N *= sign(N.z);
vec3 L = vec3(0.0, 0.0, 1.0);
float NdotL = dot(N, L);
vec3 diffuse_color = vec3(0.5) * NdotL;
color = vec4( diffuse_color.rgb, 1.0 );
}
可以是哪种类型的actions
dispatch
是否可以对某个传奇做同样的事情?
我怎么能严格地说我们只能用enum MoviesTypes {
ADD_MOVIES = 'ADD_MOVIES',
}
interface AddMoviesAction {
type: typeof MoviesTypes.ADD_MOVIES;
movies: MovieShowcase[];
}
type MoviesActionTypes =
| AddMoviesAction;
const addMovies = (movies: MovieShowcase[]): MoviesActionTypes => ({
type: MoviesTypes.ADD_MOVIES,
movies,
});
// ThunkAction<any, any, any, MoviesActionTypes> <---
// dispatch only actions inside MoviesActionTypes
const fetchNextPage = (
page: number
): ThunkAction<Promise<void>, {}, {}, MoviesActionTypes> => async (dispatch) => {
dispatch({ type: 'BAD_TYPE' }); // error
dispatch({ type: MoviesTypes.ADD_MOVIES, movies: [] }); // good
};
内的动作来调用put
?
MoviesActionTypes
答案 0 :(得分:1)
put
是通用的:
export function put<A extends Action>(action: A): PutEffect<A>
因此,只需编写受应用程序操作类型限制的put
版本:
import {
put as putUntyped,
} from "redux-saga/effects";
export const put = <A extends FetchMoviesAction>(action: A): PutEffect<A> =>
putUntyped(action);
然后在任何可能放置推土的地方使用它:
import { put } from "...";
yield put({ type: MoviesTypes.ADD_MOVIES, movies: [] });