This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
require "logger" | |
gemfile do | |
gem "graphql", "1.12.19" | |
gem "graphql-pro", "1.20.1" | |
gem "redis" | |
end | |
# Here's an example of caching parsed AST documents for persisted queries. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'bundler/inline' | |
require 'logger' | |
gemfile do | |
gem 'graphql', '2.0.12' | |
gem 'graphql-pro', '1.22.2' | |
gem 'activerecord', '7.0.2.4' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "activerecord", "7.0.2.4" | |
gem "sqlite3" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in the Context provider: | |
const interval = setInterval(() => setNow(new Date()), 1000); | |
// becomes: | |
const interval = setInterval(() => setNow(moment()), 1000); | |
// in the Component: | |
return intervalToDuration({ start: date, end: now }); | |
// becomes: | |
return moment.duration(now.diff(date)).format('HH:mm:ss'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function Timer({ date }) { | |
const { now } = useContext(TickerContext); | |
return intervalToDuration({ start: date, end: now }); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const TickerContext = React.createContext(null); | |
export function TickerProvider({ children }) { | |
const [now, setNow] = useState(new Date()); | |
useEffect(() => { | |
const interval = setInterval(() => setNow(new Date()), 1000); | |
return () => clearInterval(interval); | |
}, []); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Moment.pooledTimer = setInterval(() => { | |
Moment.pooledElements.forEach((element) => { | |
if (element.props.interval !== 0) { | |
element.update(); | |
} | |
}); | |
}, interval); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setTimer = () => { | |
const { interval } = this.props; | |
this.clearTimer(); | |
if (!Moment.pooledTimer && interval !== 0) { | |
this.timer = setInterval(() => { | |
this.update(this.props); | |
}, interval); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Moment date={date} interval={1000} format="HH:mm:ss" durationFromNow /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setInterval(() => { | |
document.getElementById('my-countdown').textContent = new Date(); | |
}, 1000) |
NewerOlder