Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit33e83ad

Browse files
committed
#000 okan add fetch polyfill
1 parent064a67a commit33e83ad

File tree

9 files changed

+126
-20
lines changed

9 files changed

+126
-20
lines changed

‎src/app/actions/authActions.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,22 @@ import { push } from 'react-router-redux'
44

55
consttokenKey="auth";
66

7+
8+
@Action("LOGIN_REQUEST")
9+
exportclassLoginRequestextendsAsyncAction{
10+
constructor(publicusername:string,publicpassword:string){
11+
super();
12+
13+
this.then(dispatch=>{
14+
fetch("https://www.google.com/search?q=${username}+${password}")
15+
returnthis;
16+
});
17+
}
18+
}
19+
720
@Action("LOGIN")
821
exportclassLoginextendsAsyncAction{
9-
constructor(publicusername:string,publicpassword:string){
22+
constructor(publictoken:string){
1023
super();
1124

1225
this.then(dispatch=>{

‎src/app/actions/index.ts‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
1-
import{ShowLoading,HideLoading}from"../utils/actionHelpers"
2-
import{ChangeTheme}from"./layoutActions"
3-
import{Login,Logout}from"./authActions"
4-
5-
export{
6-
ChangeTheme,
7-
Login,
8-
Logout,
9-
ShowLoading,
10-
HideLoading
11-
}
1+
export*from'./authActions'
2+
export*from'./layoutActions'

‎src/app/containers/Login.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22

33
import{connect}from'react-redux'
44
import{Dispatch}from"redux";
5-
import{Login}from'../actions'
5+
import{LoginRequest}from'../actions'
66

77
importPaperfrom'material-ui/Paper';
88
importTextFieldfrom'material-ui/TextField';
@@ -31,7 +31,7 @@ class LoginContainer extends React.Component<LoginProps, any>{
3131
varusername=this.refs.username.getValue();
3232
varpassword=this.refs.password.getValue();
3333

34-
this.props.dispatch(newLogin(username,password));
34+
this.props.dispatch(newLoginRequest(username,password));
3535
}
3636

3737
render(){

‎src/app/reducers/authReducer.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export const authReducer = new ReducerBuilder<AuthState>()
1111
.init({})
1212

1313
.action(Login,(state,action)=>{
14-
//async Login
15-
letusername=action.username;
16-
letpassword=action.password;
17-
1814
consttoken="token";
1915

2016
localStorage.setItem(action.getTokenKey(),token);

‎src/app/reducers/layoutReducer.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import{ReducerBuilder}from'../utils/reducerBuilder'
2-
import{ChangeTheme,ShowLoading,HideLoading}from'../actions'
2+
import{ShowLoading,HideLoading}from'../utils/actionHelpers'
3+
import{ChangeTheme}from'../actions'
34

45

56
exportinterfaceLayoutState{

‎typings.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"react":"registry:dt/react#0.14.0+20160805125551",
66
"react-dom":"registry:dt/react-dom#0.14.0+20160412154040",
77
"react-router":"registry:dt/react-router#2.0.0+20160621215300",
8-
"react-tap-event-plugin":"registry:dt/react-tap-event-plugin#0.0.0+20160602142434"
8+
"react-tap-event-plugin":"registry:dt/react-tap-event-plugin#0.0.0+20160602142434",
9+
"whatwg-fetch":"registry:dt/whatwg-fetch#0.0.0+20160728142841"
910
},
1011
"dependencies": {
1112
"lodash":"registry:npm/lodash#4.0.0+20160723033700"
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Generated by typings
2+
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/d997f92b892040860145a9510504dff22f672a36/whatwg-fetch/whatwg-fetch.d.ts
3+
declareclassRequestextendsBody{
4+
constructor(input:string|Request,init?:RequestInit);
5+
method:string;
6+
url:string;
7+
headers:Headers;
8+
context:RequestContext;
9+
referrer:string;
10+
mode:RequestMode;
11+
redirect:RequestRedirect;
12+
credentials:RequestCredentials;
13+
cache:RequestCache;
14+
}
15+
16+
interfaceRequestInit{
17+
method?:string;
18+
headers?:HeaderInit|{[index:string]:string};
19+
body?:BodyInit;
20+
mode?:RequestMode;
21+
redirect?:RequestRedirect;
22+
credentials?:RequestCredentials;
23+
cache?:RequestCache;
24+
}
25+
26+
typeRequestContext=
27+
"audio"|"beacon"|"cspreport"|"download"|"embed"|
28+
"eventsource"|"favicon"|"fetch"|"font"|"form"|"frame"|
29+
"hyperlink"|"iframe"|"image"|"imageset"|"import"|
30+
"internal"|"location"|"manifest"|"object"|"ping"|"plugin"|
31+
"prefetch"|"script"|"serviceworker"|"sharedworker"|
32+
"subresource"|"style"|"track"|"video"|"worker"|
33+
"xmlhttprequest"|"xslt";
34+
typeRequestMode="same-origin"|"no-cors"|"cors";
35+
typeRequestRedirect="follow"|"error"|"manual";
36+
typeRequestCredentials="omit"|"same-origin"|"include";
37+
typeRequestCache=
38+
"default"|"no-store"|"reload"|"no-cache"|
39+
"force-cache"|"only-if-cached";
40+
41+
declareinterfaceHeadersMap{
42+
[index:string]:string;
43+
}
44+
45+
declareclassHeaders{
46+
constructor(headers?:Headers|HeadersMap)
47+
append(name:string,value:string):void;
48+
delete(name:string):void;
49+
get(name:string):string;
50+
getAll(name:string):Array<string>;
51+
has(name:string):boolean;
52+
set(name:string,value:string):void;
53+
forEach(callback:(value:string,name:string)=>void):void;
54+
}
55+
56+
declareclassBody{
57+
bodyUsed:boolean;
58+
arrayBuffer():Promise<ArrayBuffer>;
59+
blob():Promise<Blob>;
60+
formData():Promise<FormData>;
61+
json():Promise<any>;
62+
json<T>():Promise<T>;
63+
text():Promise<string>;
64+
}
65+
66+
declareclassResponseextendsBody{
67+
constructor(body?:BodyInit,init?:ResponseInit);
68+
staticerror():Response;
69+
staticredirect(url:string,status:number):Response;
70+
type:ResponseType;
71+
url:string;
72+
status:number;
73+
ok:boolean;
74+
statusText:string;
75+
headers:Headers;
76+
clone():Response;
77+
}
78+
79+
typeResponseType="basic"|"cors"|"default"|"error"|"opaque"|"opaqueredirect";
80+
81+
interfaceResponseInit{
82+
status:number;
83+
statusText?:string;
84+
headers?:HeaderInit;
85+
}
86+
87+
declaretypeHeaderInit=Headers|Array<string>;
88+
declaretypeBodyInit=ArrayBuffer|ArrayBufferView|Blob|FormData|string;
89+
declaretypeRequestInfo=Request|string;
90+
91+
interfaceWindow{
92+
fetch(url:string|Request,init?:RequestInit):Promise<Response>;
93+
}
94+
95+
declarevarfetch:typeofwindow.fetch;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"resolution":"main",
3+
"tree": {
4+
"src":"https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/d997f92b892040860145a9510504dff22f672a36/whatwg-fetch/whatwg-fetch.d.ts",
5+
"raw":"registry:dt/whatwg-fetch#0.0.0+20160728142841",
6+
"typings":"https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/d997f92b892040860145a9510504dff22f672a36/whatwg-fetch/whatwg-fetch.d.ts"
7+
}
8+
}

‎typings/index.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
/// <reference path="globals/react-tap-event-plugin/index.d.ts" />
99
/// <reference path="globals/react/index.d.ts" />
1010
/// <reference path="globals/redux/index.d.ts" />
11+
/// <reference path="globals/whatwg-fetch/index.d.ts" />
1112
/// <reference path="modules/lodash/index.d.ts" />

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp