Generic dataloader for redux-thunk using axios Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?CRUD application using React-ReduxImplementing redirect in Redux middlewareReact/Redux 401 MiddlewareReact Redux quiz appRewriting Crime Map - React Component with ReduxReact Redux default playgroundSimple blog using react redux react-routerStatus dispatching of my redux-thunk async action (post request)A better way to retrieve data in firebase using reduxRedux: button click potentially fires 3 action for different reducers
Does the transliteration of 'Dravidian' exist in Hindu scripture? Does 'Dravida' refer to a Geographical area or an ethnic group?
Keep at all times, the minus sign above aligned with minus sign below
Is there a verb for listening stealthily?
Flight departed from the gate 5 min before scheduled departure time. Refund options
Where and when has Thucydides been studied?
newbie Q : How to read an output file in one command line
Where did Ptolemy compare the Earth to the distance of fixed stars?
malloc in main() or malloc in another function: allocating memory for a struct and its members
Did any compiler fully use 80-bit floating point?
Why complex landing gears are used instead of simple, reliable and light weight muscle wire or shape memory alloys?
Are there any irrational/transcendental numbers for which the distribution of decimal digits is not uniform?
What does 丫 mean? 丫是什么意思?
Determine whether an integer is a palindrome
As a dual citizen, my US passport will expire one day after traveling to the US. Will this work?
Vertical ranges of Column Plots in 12
Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?
Why do C and C++ allow the expression (int) + 4*5;
How to resize main filesystem
Besides transaction validation, are there any other uses of the Script language in Bitcoin
Sally's older brother
Marquee sign letters
Fit odd number of triplets in a measure?
Is this Kuo-toa homebrew race balanced?
Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?
Generic dataloader for redux-thunk using axios
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?CRUD application using React-ReduxImplementing redirect in Redux middlewareReact/Redux 401 MiddlewareReact Redux quiz appRewriting Crime Map - React Component with ReduxReact Redux default playgroundSimple blog using react redux react-routerStatus dispatching of my redux-thunk async action (post request)A better way to retrieve data in firebase using reduxRedux: button click potentially fires 3 action for different reducers
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I am developing an application where there are lots of async actions. I wanted to go with redux-saga but most have insisted to continue with redux-thunk. In redux-thunk, inside each action we have to work with async operation using then, dispatch, catch, etc. This makes looks actions so messy and lots of code will be repeated. I wanted to create a generic dataLoader for the use of redux-thunk and axios.
Here is my attempt:
export class Company
/**
* Generic api data loader
*/
static dataLoader(apiUri, onSuccess, onError, data, ...actionArguments)
const requestURL = `$API_BASE$apiuri`;
try
let options;
if (data !== undefined)
// if we have data to post
options =
method: 'POST',
url: requestURL,
body: JSON.stringify(data),
headers:
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
,
;
return function(dispatch)
axios(options)
.then(response =>
dispatch(
type: onSucess,
payload: response.data
);
)
.catch(error =>
dispatch( type: onError, payload: err);
);
static get(apiUri, onSuccess, onError, ...actionArguments)
return this.dataLoader(apiUri, onSuccess, onError, undefined, ...actionArguments);
/*
* Shorthand POST function
*/
static post(apiUri, onSuccess, onError, data, ...actionArguments)
return this.dataLoader(apiUri, onSuccess, onError, data, ...actionArguments);
I want to convert the following code to further this one:
export function showResultofApartment()
return (dispatch) =>
dispatch( type: 'APARTMENT_FETCH_START' );
const token = localStorage.getItem('token');
return axios.get(`$API_URL/newoffers/apartment/`)
.then((response) =>
console.log('response apart', response.data);
dispatch( type: 'APARTMENT_FETCH_SUCCESS', payload: response.data );
)
.catch((err) =>
dispatch( type: 'APARTMENT_FETCH_FAILURE', payload: err );
);
;
to such or more efficient than this:
export function showResultofApartment()
return(dispatch) =>
dispatch( type: APARTMENT_FETCH_START );
const token = localStorage.getItem('token');
return Company.get('/apartments', APARTMENT_FETCH_SUCCESS, APARTMENT_FETCH_ERROR);
// if post then Company.post('/apartment', APARTMENT_POST_SUCCESS, APARTMENT_POST_ERROR, data)
I have not tested this. I am just throwing my idea through code to get other experts idea on how I should handle such case for a more efficient technique without using other more external libraries.
javascript react.js redux
$endgroup$
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
$begingroup$
I am developing an application where there are lots of async actions. I wanted to go with redux-saga but most have insisted to continue with redux-thunk. In redux-thunk, inside each action we have to work with async operation using then, dispatch, catch, etc. This makes looks actions so messy and lots of code will be repeated. I wanted to create a generic dataLoader for the use of redux-thunk and axios.
Here is my attempt:
export class Company
/**
* Generic api data loader
*/
static dataLoader(apiUri, onSuccess, onError, data, ...actionArguments)
const requestURL = `$API_BASE$apiuri`;
try
let options;
if (data !== undefined)
// if we have data to post
options =
method: 'POST',
url: requestURL,
body: JSON.stringify(data),
headers:
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
,
;
return function(dispatch)
axios(options)
.then(response =>
dispatch(
type: onSucess,
payload: response.data
);
)
.catch(error =>
dispatch( type: onError, payload: err);
);
static get(apiUri, onSuccess, onError, ...actionArguments)
return this.dataLoader(apiUri, onSuccess, onError, undefined, ...actionArguments);
/*
* Shorthand POST function
*/
static post(apiUri, onSuccess, onError, data, ...actionArguments)
return this.dataLoader(apiUri, onSuccess, onError, data, ...actionArguments);
I want to convert the following code to further this one:
export function showResultofApartment()
return (dispatch) =>
dispatch( type: 'APARTMENT_FETCH_START' );
const token = localStorage.getItem('token');
return axios.get(`$API_URL/newoffers/apartment/`)
.then((response) =>
console.log('response apart', response.data);
dispatch( type: 'APARTMENT_FETCH_SUCCESS', payload: response.data );
)
.catch((err) =>
dispatch( type: 'APARTMENT_FETCH_FAILURE', payload: err );
);
;
to such or more efficient than this:
export function showResultofApartment()
return(dispatch) =>
dispatch( type: APARTMENT_FETCH_START );
const token = localStorage.getItem('token');
return Company.get('/apartments', APARTMENT_FETCH_SUCCESS, APARTMENT_FETCH_ERROR);
// if post then Company.post('/apartment', APARTMENT_POST_SUCCESS, APARTMENT_POST_ERROR, data)
I have not tested this. I am just throwing my idea through code to get other experts idea on how I should handle such case for a more efficient technique without using other more external libraries.
javascript react.js redux
$endgroup$
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
$begingroup$
I am developing an application where there are lots of async actions. I wanted to go with redux-saga but most have insisted to continue with redux-thunk. In redux-thunk, inside each action we have to work with async operation using then, dispatch, catch, etc. This makes looks actions so messy and lots of code will be repeated. I wanted to create a generic dataLoader for the use of redux-thunk and axios.
Here is my attempt:
export class Company
/**
* Generic api data loader
*/
static dataLoader(apiUri, onSuccess, onError, data, ...actionArguments)
const requestURL = `$API_BASE$apiuri`;
try
let options;
if (data !== undefined)
// if we have data to post
options =
method: 'POST',
url: requestURL,
body: JSON.stringify(data),
headers:
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
,
;
return function(dispatch)
axios(options)
.then(response =>
dispatch(
type: onSucess,
payload: response.data
);
)
.catch(error =>
dispatch( type: onError, payload: err);
);
static get(apiUri, onSuccess, onError, ...actionArguments)
return this.dataLoader(apiUri, onSuccess, onError, undefined, ...actionArguments);
/*
* Shorthand POST function
*/
static post(apiUri, onSuccess, onError, data, ...actionArguments)
return this.dataLoader(apiUri, onSuccess, onError, data, ...actionArguments);
I want to convert the following code to further this one:
export function showResultofApartment()
return (dispatch) =>
dispatch( type: 'APARTMENT_FETCH_START' );
const token = localStorage.getItem('token');
return axios.get(`$API_URL/newoffers/apartment/`)
.then((response) =>
console.log('response apart', response.data);
dispatch( type: 'APARTMENT_FETCH_SUCCESS', payload: response.data );
)
.catch((err) =>
dispatch( type: 'APARTMENT_FETCH_FAILURE', payload: err );
);
;
to such or more efficient than this:
export function showResultofApartment()
return(dispatch) =>
dispatch( type: APARTMENT_FETCH_START );
const token = localStorage.getItem('token');
return Company.get('/apartments', APARTMENT_FETCH_SUCCESS, APARTMENT_FETCH_ERROR);
// if post then Company.post('/apartment', APARTMENT_POST_SUCCESS, APARTMENT_POST_ERROR, data)
I have not tested this. I am just throwing my idea through code to get other experts idea on how I should handle such case for a more efficient technique without using other more external libraries.
javascript react.js redux
$endgroup$
I am developing an application where there are lots of async actions. I wanted to go with redux-saga but most have insisted to continue with redux-thunk. In redux-thunk, inside each action we have to work with async operation using then, dispatch, catch, etc. This makes looks actions so messy and lots of code will be repeated. I wanted to create a generic dataLoader for the use of redux-thunk and axios.
Here is my attempt:
export class Company
/**
* Generic api data loader
*/
static dataLoader(apiUri, onSuccess, onError, data, ...actionArguments)
const requestURL = `$API_BASE$apiuri`;
try
let options;
if (data !== undefined)
// if we have data to post
options =
method: 'POST',
url: requestURL,
body: JSON.stringify(data),
headers:
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
,
;
return function(dispatch)
axios(options)
.then(response =>
dispatch(
type: onSucess,
payload: response.data
);
)
.catch(error =>
dispatch( type: onError, payload: err);
);
static get(apiUri, onSuccess, onError, ...actionArguments)
return this.dataLoader(apiUri, onSuccess, onError, undefined, ...actionArguments);
/*
* Shorthand POST function
*/
static post(apiUri, onSuccess, onError, data, ...actionArguments)
return this.dataLoader(apiUri, onSuccess, onError, data, ...actionArguments);
I want to convert the following code to further this one:
export function showResultofApartment()
return (dispatch) =>
dispatch( type: 'APARTMENT_FETCH_START' );
const token = localStorage.getItem('token');
return axios.get(`$API_URL/newoffers/apartment/`)
.then((response) =>
console.log('response apart', response.data);
dispatch( type: 'APARTMENT_FETCH_SUCCESS', payload: response.data );
)
.catch((err) =>
dispatch( type: 'APARTMENT_FETCH_FAILURE', payload: err );
);
;
to such or more efficient than this:
export function showResultofApartment()
return(dispatch) =>
dispatch( type: APARTMENT_FETCH_START );
const token = localStorage.getItem('token');
return Company.get('/apartments', APARTMENT_FETCH_SUCCESS, APARTMENT_FETCH_ERROR);
// if post then Company.post('/apartment', APARTMENT_POST_SUCCESS, APARTMENT_POST_ERROR, data)
I have not tested this. I am just throwing my idea through code to get other experts idea on how I should handle such case for a more efficient technique without using other more external libraries.
javascript react.js redux
javascript react.js redux
edited May 31 '17 at 2:45
Jamal♦
30.6k11121227
30.6k11121227
asked May 31 '17 at 2:31
TushantTushant
1563
1563
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
This is one of the problems with async actions in redux-thunk. As you point out you have to create constants for "APARTMENT_FETCH_STATUS" and manually dispatch actions of this type before and after the request has been done.
The redux-promise-middleware library actually does all this for you. You simply create an action like so:
const foo = () => (
type: 'FOO',
payload: new Promise()
);
and the library will take care of dispatching an action of type "FOO_PENDING", and then of type "FOO_FULFILLED" when the promise has resolved. With redux-promise-middleware your actions would become something like this:
const showResultOfApartment = () => (
type: "FETCH_APARTMENT",
payload: axios.get("http://api.com/apartments").then(result => result.data)
)
In your reducer you would create handlers for "FETCH_APARTMENT_PENDING", "FETCH_APARTMENT_FULFILLED" and "FETCH_APARTMENT_REJECTED". In the case where the promise fulfills or rejects, you also get the result of the promise by accessing action.payload
. An example of what it could look like:
function apartmentReducer(state, action)
if(action.type === "FETCH_APARTMENT_PENDING")
return Object.assign(, state, loading: true )
else if(action.type === "FETCH_APARTMENT_FULFILLED")
return Object.assign(, state, loading: false, apartment: action.payload )
else if(action.type === "FETCH_APARTMENT_REJECTED")
return Object.assign(, state, loading: false, error: action.payload )
return state;
redux-promise-middleware
Introduction to redux-promise-middleware
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f164570%2fgeneric-dataloader-for-redux-thunk-using-axios%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
This is one of the problems with async actions in redux-thunk. As you point out you have to create constants for "APARTMENT_FETCH_STATUS" and manually dispatch actions of this type before and after the request has been done.
The redux-promise-middleware library actually does all this for you. You simply create an action like so:
const foo = () => (
type: 'FOO',
payload: new Promise()
);
and the library will take care of dispatching an action of type "FOO_PENDING", and then of type "FOO_FULFILLED" when the promise has resolved. With redux-promise-middleware your actions would become something like this:
const showResultOfApartment = () => (
type: "FETCH_APARTMENT",
payload: axios.get("http://api.com/apartments").then(result => result.data)
)
In your reducer you would create handlers for "FETCH_APARTMENT_PENDING", "FETCH_APARTMENT_FULFILLED" and "FETCH_APARTMENT_REJECTED". In the case where the promise fulfills or rejects, you also get the result of the promise by accessing action.payload
. An example of what it could look like:
function apartmentReducer(state, action)
if(action.type === "FETCH_APARTMENT_PENDING")
return Object.assign(, state, loading: true )
else if(action.type === "FETCH_APARTMENT_FULFILLED")
return Object.assign(, state, loading: false, apartment: action.payload )
else if(action.type === "FETCH_APARTMENT_REJECTED")
return Object.assign(, state, loading: false, error: action.payload )
return state;
redux-promise-middleware
Introduction to redux-promise-middleware
$endgroup$
add a comment |
$begingroup$
This is one of the problems with async actions in redux-thunk. As you point out you have to create constants for "APARTMENT_FETCH_STATUS" and manually dispatch actions of this type before and after the request has been done.
The redux-promise-middleware library actually does all this for you. You simply create an action like so:
const foo = () => (
type: 'FOO',
payload: new Promise()
);
and the library will take care of dispatching an action of type "FOO_PENDING", and then of type "FOO_FULFILLED" when the promise has resolved. With redux-promise-middleware your actions would become something like this:
const showResultOfApartment = () => (
type: "FETCH_APARTMENT",
payload: axios.get("http://api.com/apartments").then(result => result.data)
)
In your reducer you would create handlers for "FETCH_APARTMENT_PENDING", "FETCH_APARTMENT_FULFILLED" and "FETCH_APARTMENT_REJECTED". In the case where the promise fulfills or rejects, you also get the result of the promise by accessing action.payload
. An example of what it could look like:
function apartmentReducer(state, action)
if(action.type === "FETCH_APARTMENT_PENDING")
return Object.assign(, state, loading: true )
else if(action.type === "FETCH_APARTMENT_FULFILLED")
return Object.assign(, state, loading: false, apartment: action.payload )
else if(action.type === "FETCH_APARTMENT_REJECTED")
return Object.assign(, state, loading: false, error: action.payload )
return state;
redux-promise-middleware
Introduction to redux-promise-middleware
$endgroup$
add a comment |
$begingroup$
This is one of the problems with async actions in redux-thunk. As you point out you have to create constants for "APARTMENT_FETCH_STATUS" and manually dispatch actions of this type before and after the request has been done.
The redux-promise-middleware library actually does all this for you. You simply create an action like so:
const foo = () => (
type: 'FOO',
payload: new Promise()
);
and the library will take care of dispatching an action of type "FOO_PENDING", and then of type "FOO_FULFILLED" when the promise has resolved. With redux-promise-middleware your actions would become something like this:
const showResultOfApartment = () => (
type: "FETCH_APARTMENT",
payload: axios.get("http://api.com/apartments").then(result => result.data)
)
In your reducer you would create handlers for "FETCH_APARTMENT_PENDING", "FETCH_APARTMENT_FULFILLED" and "FETCH_APARTMENT_REJECTED". In the case where the promise fulfills or rejects, you also get the result of the promise by accessing action.payload
. An example of what it could look like:
function apartmentReducer(state, action)
if(action.type === "FETCH_APARTMENT_PENDING")
return Object.assign(, state, loading: true )
else if(action.type === "FETCH_APARTMENT_FULFILLED")
return Object.assign(, state, loading: false, apartment: action.payload )
else if(action.type === "FETCH_APARTMENT_REJECTED")
return Object.assign(, state, loading: false, error: action.payload )
return state;
redux-promise-middleware
Introduction to redux-promise-middleware
$endgroup$
This is one of the problems with async actions in redux-thunk. As you point out you have to create constants for "APARTMENT_FETCH_STATUS" and manually dispatch actions of this type before and after the request has been done.
The redux-promise-middleware library actually does all this for you. You simply create an action like so:
const foo = () => (
type: 'FOO',
payload: new Promise()
);
and the library will take care of dispatching an action of type "FOO_PENDING", and then of type "FOO_FULFILLED" when the promise has resolved. With redux-promise-middleware your actions would become something like this:
const showResultOfApartment = () => (
type: "FETCH_APARTMENT",
payload: axios.get("http://api.com/apartments").then(result => result.data)
)
In your reducer you would create handlers for "FETCH_APARTMENT_PENDING", "FETCH_APARTMENT_FULFILLED" and "FETCH_APARTMENT_REJECTED". In the case where the promise fulfills or rejects, you also get the result of the promise by accessing action.payload
. An example of what it could look like:
function apartmentReducer(state, action)
if(action.type === "FETCH_APARTMENT_PENDING")
return Object.assign(, state, loading: true )
else if(action.type === "FETCH_APARTMENT_FULFILLED")
return Object.assign(, state, loading: false, apartment: action.payload )
else if(action.type === "FETCH_APARTMENT_REJECTED")
return Object.assign(, state, loading: false, error: action.payload )
return state;
redux-promise-middleware
Introduction to redux-promise-middleware
answered May 31 '17 at 18:58
MattMatt
18615
18615
add a comment |
add a comment |
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f164570%2fgeneric-dataloader-for-redux-thunk-using-axios%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown