#How am i gonna send request live-server when dateTime is matched?

17 messages · Page 1 of 1 (latest)

wise spade
#

how am i gonna send request to server whenever the time is expire or matched? i mean the request should be sended automatically live to the server without any kind of user interaction. lets say there is a sale which last day is today, so i want to expire it by its own when mid-night 12:00 reached

robust apex
twilit osprey
#

1st param can be either number or date and according to description:

#

... or a Date until which the emission of the source items is delayed.

#

it should delay emission until provided date

#

also example from docs

#
import { fromEvent, delay } from 'rxjs';

const clicks = fromEvent(document, 'click');
const date = new Date('March 15, 2050 12:00:00'); // in the future
const delayedClicks = clicks.pipe(delay(date)); // click emitted only after that date
delayedClicks.subscribe(x => console.log(x));
wise spade
#

ohh so, delay operator can also allow the date

twilit osprey
#

yes and it basically calculates number of ms between current date and provided and sets a delay

#

so no magic or periodically executed jobs

twilit osprey
#

just setTimeout

wise spade
#

it make it so easy for the future actions

robust apex
#

Anyway if you want to search more, what you want to achieve is called Polling

#

You can do it either in backend or frontend