pen

UTI - Retirement Benefit Pension Fund - Regular Plan

Category Solution Oriented Scheme - Retirement Fund
NAV 23.4658
Repurchase Price
Sale Price
Date 08-May-2020




pen

Merkel says Germany's re-opening will have 'emergency brake' in case Covid-19 spikes

Chancellor Angela Merkel announced steps on Wednesday to ease the coronavirus lockdown in Germany but at the same time launched an "emergency brake" mechanism allowing for renewed restrictions in case infections pick up again.





pen

Confinement, week #8: Spotlight on reopening schools, small-scale farmers and more

With France now in its eighth and final week of full lockdown due to the coronavirus pandemic, FRANCE 24 brings you four reports on the consequences in Paris and around the country.




pen

Open Science Essentials: Preprints

Open science essentials in 2 minutes, part 4 Before a research article is published in a journal you can make it freely available for anyone to read. You could do this on your own website, but you can also do it on a preprint server, such as psyarxiv.com, where other researchers also share their preprints, … Continue reading "Open Science Essentials: Preprints"





pen

nothing happening in the news

Today on Toothpaste For Dinner: nothing happening in the news


WE NEED YOUR HELP: Please chip in $1 or more on Patreon so I can continue to update Toothpaste For Dinner, Married To The Sea & The Worst Things For Sale online and updating daily. I can not do this without your support on Patreon.












pen

Scandal Engulfs Independent Publisher ChiZine Publications


Posted by Victoria Strauss for Writer Beware®

If you're not part of the horror or speculative fiction community, you may not be aware of the scandal that over the past two weeks has engulfed ChiZine Publications, a (previously) highly-regarded Canadian independent publisher.

In September of last year, several authors, including Ed Kurtz, made a complaint to the Horror Writers Association about long-overdue royalties at ChiZine. On November 5 of this year, after the complaint became public knowledge, CZP posted a statement on its Facebook page, claiming that Kurtz's royalties were "currently paid in full" and that "Any other monies he might be due will be paid on his next royalty statement". Kurtz's response, posted by his partner on Facebook a day later, was blistering:
The statement from Chizine neglects a number of salient facts, such as the moment in July 2018, at Necon, when I explained to Brett Savory that my partner was facing a layoff, our cat was ill, we were in severe financial distress, and I had *never* been paid a single cent of royalties in what was at that time almost two years for a moderately successful book. He actually grinned and said, "Things are hard for everyone right now" before walking away. The following morning it was reported to me that Sandra was loudly complaining in the dealer room about me having asked about my royalties, and of course the two of them went on a whirlwind trip around the world a few weeks after that, showing us all that things weren't so rough for them, after all.

In fact, I'd asked after my royalties several times and was rebuffed or given excuses every single time (usually something wrong with their accounting software or something similar, which I later learned they’d been saying to authors for years). I only went to the HWA after several other frustrated CZP authors (one of whom hadn't been paid in five years!) strongly encouraged me to do so. I expressed fear of bullying and/or retaliation, and some of these authors promised me they'd have my back (they didn't). And yes, a lot of us got paid through my efforts, though it is untrue I'm paid in full. I was never paid royalties for the months of my first year of publication, 2016, though CZP continues to claim I was. I just gave up on this.
Kurtz's experience was not isolated.

******

Between 2010 and 2015, Writer Beware received a handful of complaints (fewer than five) about ChiZine from authors who cited months-late royalty payments or long waits for contracts. Because the complaints were so few, and also because the authors all did eventually receive their payments or their contracts (though in most cases only after persistent prodding), it wasn't clear to me whether the tardiness indicated a pattern of problems, or was the kind of occasional glitch that can afflict otherwise reputable small presses with small staff and tight finances.

As it turns out, those few complaints were just the tiniest bubbles drifting up from what appears to be a roiling ocean of dysfunction.

Following Kurtz's public response, CZP authors and staff began to come forward with their own experiences--a tsunami of serious allegations including non-payment (some staff say they were never paid for years of work), extremely late or missing royalty payments (years in arrears in some cases; many authors report having to fight for what payment was received), erratically-produced royalty statements (CZP breached at least some of its own contracts by sending out royalties once a year instead of bi-annually--more on that below), missed pub dates, broken marketing promises, and financial mismanagement--especially concerning, since a big chunk of CZP's budget comes from grants and subsidies. (Former CZP staff member Michael Matheson has written a pair of illuminating posts on CZP's finances, including its treatment of grant money and habitual financial distress.)

Staff and authors also--in multiple, strikingly similar posts and complaints, including some received by Writer Beware--cite a toxic work culture that featured bullying, intimidation, sexual harassment, racism, gaslighting, and more. Several of those who contacted me told me that they felt CZP operated "like a cult," with charismatic leaders at the top who were admired and feared in equal measure, and whom many dared not defy.

This account only scratches the surface. For much more:
On November 11, CZP's founders, Sandra Kasturi and Brett Savory, posted a statement on the CZP blog and Facebook page indicating that they have decided to "step down." Although the statement mentions financial issues ("we have taken a short-term personal loan to bring payments up to date"), it doesn't address the many other complaints that have been leveled against the company--and, notably, does not include an apology.

The response has not been kind.

******

Despite all of the above, there are still those who continue to defend CZP, and to brush off the statements by writers and staff. For example, this, from editor Stephen Jones (Jones's post has been removed; this is a screenshot posted to Twitter):

What stands out for me here is not just the skepticism that whistleblowers always have to face (and which, even when the publisher doesn't try to intimidate or engage in reprisals, makes it so much harder for whistleblowers to come forward), but the defense of unprofessional business practice--not just by CZP but, apparently, by small press publishers in general. Small presses are doing something great for writers and readers, so we should "cut them some slack" when they fail to pay, or don't fill book orders, or miss a pub date, or engage in some other kind of behavior that has a negative impact on staff and authors. That's "simply the nature of small press publishing." Deal with it!

It's a really common argument. I can't tell you how often I've seen some version of it--not just from toxic or troubled publishers, but from the writers they are screwing over. But it is bullshit. Complete and utter bullshit.

No matter how "worthy" a publisher may be, that does not give it the right to abuse its writers or its staff--whether by accident or design. Publishers function in the realm of art, but they also need to function like businesses--not like cults of personality, not like sinecures, not like kitchen-table hobby projects where it doesn't really matter that they know little about publishing and have never run a business as long as they've got good intentions. You don't get a pass because you've got a noble goal. You don't get a pass because independent publishers are struggling and we need more of them. You don't even get a pass because you're putting out good books from disenfranchised authors. You need to run your business right, and treat your writers and your staff right, or you have no business calling yourself a publisher.

Which brings me to my next point. The scope and range of what has apparently been happening at ChiZine is bigger than usual (and having seen as many small press implosions as I have over the years, it's amazing to me that it took so long for the scandal to break). But it's important to emphasize that it is not an isolated occurrence. Contract breaches, financial malfeasance, even the kind of harassment and gaslighting and dictatorial behavior that CZP authors and staff describe--all are rampant in the small press world. Just go back through a few years of the entries on this blog, and you'll see plenty of examples.

I don't mean to tar all small presses with the same brush. There are, it's important to acknowledge, many small and indie publishers that operate with complete professionalism and do all they can to treat their authors right. But there is a huge, huge problem in the small press segment of the publishing industry, and we don't do writers--or readers--any favors in dismissing or downplaying or making excuses for it.

I'm not the only one who is making this point. Silvia Moreno-Garcia, who had payment issues with CZP and also has experience running a micro-press, addresses the issue in a Twitter thread:


In a blog post, former CZP staffer Michael Matheson responds to those who would like to see publishers like CZP dealt with more kindly:

And, commenting on the Chizine situation, writer and reviewer Gabino Iglesias points out:


I agree 100%. But I'm not holding my breath.

******

The scandal has unfolded very quickly but there've already been consequences. High Fever Books reports "a mass exodus" from CZP, with authors requesting rights reversions for their books, and withdrawing stories from CZP's forthcoming Christmas anthology. The Ontario Arts Council, one of CZP's funders, has recently removed CZP from its list of grant recommenders. And SFWA has issued a statement:


******

Finally, some semi-wonky publishing stuff.

There's been some discussion of irregularities with CZP's royalty statements. I've seen a number of these, kindly shared with me by CZP authors, and while they're somewhat of a chore to figure out and are missing some information that ideally should be present, the numbers do add up. However, a few things are sub-optimal.

- CZP's contract boilerplate empowers the publisher to set a "reasonable" reserve against returns. There are no specifics, so it's basically up to the publisher to decide what "reasonable" is.

For CZP, "reasonable" seems to mean 50%. This seemed high to me, so I did a mini-canvass of literary agents on Twitter. Most agreed that smaller is better--maybe 25-30%, though some felt that 50% was justifiable depending on the circumstances. They also pointed out that the reserve percentage should fall in subsequent reporting periods (CZP's remains at 50%, unless boilerplate has been negotiated otherwise), and that publishers should not hold reserves beyond two or three years, or four or five accounting periods (CZP has held reserves for some authors for much longer).

(If you're unclear on what a reserve against returns is, here's an explanation.)

- Per CZP's contract, royalties are paid "by the first royalty period falling one year after publication." What this means in practice (based on the royalty statements I saw) is that if your pub date is (hypothetically) April of 2016, you are not eligible for payment until the first royalty period that follows your one-year anniversary--which, since CZP pays royalties just once a year on a January-December schedule, would be the royalty period ending December 2017. Since publishers often take months to issue royalty statements and payments following the end of a royalty period, you'd get no royalty check until sometime in 2018--close to, or possibly more than, two full years after publication.

In effect, CZP is setting a 100% reserve against returns for at least a year following publication, and often much more. This gives it the use of the author's money for far too long, not to mention a financial cushion that lets it write smaller checks, since it doesn't have to pay anything out until after returns have come in (most sales and most returns occur during the first year of release).

I shouldn't need to say that this is non-standard. It's also, in my opinion, seriously exploitative.

- And...about that annual payment. It too is non-standard--even the big houses pay twice a year, and most small publishers pay quarterly or even more often. It's also extra-contractual--at least for the contracts I saw. According to CZP's boilerplate, payments are supposed to be bi-annual after that initial year-or-more embargo. The switch to annual payment appears to have been a unilateral decision by CZP owners for logistical and cost reasons, actual contract language be damned (I've seen documentation of this).

- A final wonky contract point: CZP's contract boilerplate mentions royalty payments (as in, they're bi-annual)--but does not, anywhere, mention royalty statements.

A publishing contract absolutely needs to bind a publisher not just to pay, but to account royalties on a regular basis (whether or not payments are due). If there's no contractual obligation for the publisher to provide royalty accounting, it may decline to do so--and that's not theoretical, I've gotten more than a few complaints about exactly this. Just one more reason to get knowledgeable advice on any publishing contract you're thinking of signing.





pen

Biting passengers on flight is no reason for cash compensation delay: EU court adviser

Air travelers cannot receive cash compensation if their flight is delayed by a passenger biting others and assaulting crew members, an adviser at the Court of Justice of the European Union said on Thursday.




pen

Thailand's pet groomer reopens as new coronavirus cases slow

Chewy and Miley, both two-year-old Schnauzer dogs, are getting their hair cut at a groomer in Bangkok for the first time since the new coronavirus outbreak began in Thailand in January.




pen

Clawing back normality: Bangkok cat cafe reopens after virus shutdown

As Thailand's capital cautiously reopens many restaurants shuttered over coronavirus fears, the feline "employees" of the Caturday Cafe are back at work.




pen

'People's lives depend on it': the sacked English defender left in limbo | Sid Lowe

Charlie I’Anson’s contract in the third tier has been terminated but the lockdown has left him unable to travel

Charlie I’Anson spent Thursday packing up boxes in the small flat he rents near Madrid, finalising the details of his dismissal from the football club for whom he played, and trying to contact the police to request permission to travel home. The night before, the news slipped out: two months after the last match, and on the day the first and second division players returned to work, the football federation decided to cancel the rest of the season in Spain’s third and fourth tiers. Like thousands of footballers, the English centre-back’s season was over with 10 matches remaining.

Related: Covid-19's impact on football: 'It could take 10 years to get where we were'

Continue reading...




pen

Reopening Mississippi: America's poorest state begins lifting lockdown

Despite rising coronavirus case numbers, the US state of Mississippi is moving out of lockdown and reopening parks, restaurants and other non-essential shops. Oliver Laughland went to the resort of Biloxi to see how residents were responding

The US southern state of Mississippi is the country’s poorest. It went into the coronavirus crisis with high levels of poverty and poor health outcomes. But following the period of lockdown and orders for residents to stay at home, the state’s governor Tate Reeves has eased restrictions - despite evidence that the rate of infections has not yet hit its peak.

The Guardian’s Oliver Laughland travelled to the Mississippi coastal resort of Biloxi where he tells Mythili Rao he found the lockdown has hit hardest those working in low paid jobs in the tourism industry. One restaurant worker describes how the loss of work meant he has had to rely on the charity of his neighbours and local food banks. But despite growing numbers of cases, people are flocking back to the beach and increasingly breaching recommendations of minimum social distancing. The state is reopening, but at what cost?

Continue reading...




pen

The real Lord of the Flies: what happened when six boys were shipwrecked for 15 months

When a group of schoolboys were marooned on an island in 1965, it turned out very differently from William Golding’s bestseller, writes Rutger Bregman

For centuries western culture has been permeated by the idea that humans are selfish creatures. That cynical image of humanity has been proclaimed in films and novels, history books and scientific research. But in the last 20 years, something extraordinary has happened. Scientists from all over the world have switched to a more hopeful view of mankind. This development is still so young that researchers in different fields often don’t even know about each other.

When I started writing a book about this more hopeful view, I knew there was one story I would have to address. It takes place on a deserted island somewhere in the Pacific. A plane has just gone down. The only survivors are some British schoolboys, who can’t believe their good fortune. Nothing but beach, shells and water for miles. And better yet: no grownups.

Continue reading...




pen

Plan to open schools on 1 June in doubt as unions air safety fears

Joint statement insists return will not happen until stringent ‘test and trace’ regime in place

Ministers’ plans to reopen schools as early as 1 June are in serious doubt after unions representing teachers and school staff insisted that they would not consider a return without a stringent coronavirus “test and trace” regime.

In an unusual joint statement, which one senior union official said indicated that an early return to a normal school timetable was “off the menu”, the Trades Union Congress said that there should be “no increase in pupil numbers until full rollout of a national test and trace scheme”, and called for the establishment of a Covid-19 taskforce with government, unions and others to agree on the safe reopening of schools.

Continue reading...




pen

'Harvesting' is a terrible word – but it's what has happened in Britain's care homes | Richard Coker

Epidemiologists use the term to describe tragic excess deaths – but for Covid-19 it seems to be the de facto government policy

There’s a term we use in epidemiology to capture the essence of increases in deaths, or excess mortality, above and beyond normal expectations: “harvesting”. During heatwaves, or a bad season of influenza, additional deaths above what would be normally seen in the population fit this description. Harvesting usually affects older people and those who are already sick. Generally, it is viewed as a tragic, unfortunate, but largely unpreventable consequence of natural events. It carries with it connotations of an acceptable loss of life. It is, in a sense, what happens as part of a normal life in normal times. But the word also has darker connotations: those of sacrifice, reaping, culling. As such, while it may appear in textbooks of epidemiology, it doesn’t occur in national influenza strategic plans or national discourse. The concept of harvesting is restricted to epidemiological circles.

But what if politicians promote the notion of harvesting (while declining to use the term) where it is not a “natural” consequence of events but a direct consequence of government policy? What if the medical and nursing world do not accept harvesting in these circumstances? What if a policy that results in harvesting cannot be articulated because it is unacceptable to the broader population? This is where we have got to with the coronavirus pandemic. Nowhere better exemplifies this tension between a policy and its popular acceptance than the effects of coronavirus in nursing homes.

Continue reading...




pen

'You can't ask the virus for a truce': reopening America is Trump's biggest gamble

With states opening even as Covid-19 rages on, the president is rolling the dice on his career – and tens of thousands of lives

On Monday the Republican governor of Nebraska, Pete Ricketts, a close ally of Donald Trump and frequent visitor to the White House, opened his daily coronavirus briefing with a big announcement. “Today is May 4,” he said, “the first day of loosened restrictions statewide.”

With his declaration, Ricketts placed Nebraska at the vanguard of America’s reopening. Churches can now open their doors to worshippers, wedding bells and funeral dirges will be heard once more, hospitals can reschedule elective surgeries, and most Nebraskans will be able to resumehaving their hair cut, nails manicured, bodies massaged and skin tattooed.

Continue reading...




pen

Open Laser Blaster Shells Out More Bang for the Buck

[a-RN-au-D] was looking for something fun to do with his son and dreamed up a laser blaster game that ought to put him in the running for father of the year. It was originally just going to be made of cardboard, but you know how these things go. We’re happy …read more




pen

Coronavirus: What does evidence say about schools reopening?

Many studies suggest coronavirus has low transmission rates among children, but there are still risks to reopening schools that were closed due to social distancing policies




pen

Covid-19 shows why an infodemic of bad science must never happen again

Once the coronavirus pandemic is over, we must work out how to stop the spread of poor information that has helped make a bad situation that much worse




pen

Friday Polynews Roundup — Polyamory in the time of coronavirus, 'Trigonometry' and 'Open' begin on TV, research on ethics in the poly community, and more




pen

Friday Polynews Roundup — When this isolation ends, good long-distance sex, how to open a relationship, and more.





pen

Russia is fast becoming a coronavirus epicenter, with health workers still reporting PPE shortages. Putin is already thinking about reopening.

On Thursday, the country reported its largest one-day increase in new cases of 11,231 — yet President Putin already has his eyes on reopening.





pen

Katie Miller, Pence spokeswoman, tests positive for coronavirus

The diagnosis brings the threat of infection into the president's inner circle.





pen

Plastic shields in place, Dutch schools to reopen amid coronavirus

At the Springplank school in the Dutch city of Den Bosch, staff have installed plastic shields around students' desks and disinfectant gel dispensers at the doorways as part of preparations to reopen amid the country's coronavirus outbreak. New infections in the Netherlands have been declining for weeks, and the government on Wednesday announced a schedule to relax some of its lockdown measures, with elementary schools to reopen on May 11. "Our teachers are not worried," said Rascha van der Sluijs, the school's technical coordinator.





pen

Coronavirus: Are dentists open for emergency care? And other questions

Are dentists open for emergency care, and other questions answered by BBC experts.




pen

Labour Party: Starmer moves to rein in shadow cabinet spending plans

Leaked letter from shadow minister reveals attempt to impose discipline on top team, writes Iain Watson.




pen

Why are MPs keen for garden centres to re-open?

From boosting the economy through to health benefits, Westminster has been talking up the measure.




pen

US shopping centres re-open: 'This is the best day ever'

In states like Texas, malls can operate at a 25% capacity and for some, it's a reason to get out of the house.




pen

US Vice-President Mike Pence's aide tests positive for coronavirus

The diagnosis comes one day after Trump's personal valet tested positive for the virus.




pen

Coronavirus: 'Phone apps helped me spend time with my dying mum'

Andrew's mother was dying in hospital under lockdown, so he used technology to spend time with her.




pen

Coronavirus: Schools in Wales not reopening on 1 June

The situation for schools in Wales will not change on 1 June, the education minister says.




pen

Coronavirus: Key safeguards needed for schools to reopen - unions

Education unions say they want scientific evidence it is safe for teachers and pupils to return.




pen

Coronavirus: When might Hollywood reopen for business?

Cast and crews might have to quarantine together in the future when filming begins again.




pen

ICYMI: Penguin chicks and new dining ideas

Some of the stories from around the world that you may have missed this week.




pen

Building Great User Experiences with Concurrent Mode and Suspense

At React Conf 2019 we announced an experimental release of React that supports Concurrent Mode and Suspense. In this post we’ll introduce best practices for using them that we’ve identified through the process of building the new facebook.com.

This post will be most relevant to people working on data fetching libraries for React.

It shows how to best integrate them with Concurrent Mode and Suspense. The patterns introduced here are based on Relay — our library for building data-driven UIs with GraphQL. However, the ideas in this post apply to other GraphQL clients as well as libraries using REST or other approaches.

This post is aimed at library authors. If you’re primarily an application developer, you might still find some interesting ideas here, but don’t feel like you have to read it in its entirety.

Talk Videos

If you prefer to watch videos, some of the ideas from this blog post have been referenced in several React Conf 2019 presentations:

This post presents a deeper dive on implementing a data fetching library with Suspense.

Putting User Experience First

The React team and community has long placed a deserved emphasis on developer experience: ensuring that React has good error messages, focusing on components as a way to reason locally about app behavior, crafting APIs that are predictable and encourage correct usage by design, etc. But we haven’t provided enough guidance on the best ways to achieve a great user experience in large apps.

For example, the React team has focused on framework performance and providing tools for developers to debug and tune application performance (e.g. React.memo). But we haven’t been as opinionated about the high-level patterns that make the difference between fast, fluid apps and slow, janky ones. We always want to ensure that React remains approachable to new users and supports a variety of use-cases — not every app has to be “blazing” fast. But as a community we can and should aim high. We should make it as easy as possible to build apps that start fast and stay fast, even as they grow in complexity, for users on varying devices and networks around the world.

Concurrent Mode and Suspense are experimental features that can help developers achieve this goal. We first introduced them at JSConf Iceland in 2018, intentionally sharing details very early to give the community time to digest the new concepts and to set the stage for subsequent changes. Since then we’ve completed related work, such as the new Context API and the introduction of Hooks, which are designed in part to help developers naturally write code that is more compatible with Concurrent Mode. But we didn’t want to implement these features and release them without validating that they work. So over the past year, the React, Relay, web infrastructure, and product teams at Facebook have all collaborated closely to build a new version of facebook.com that deeply integrates Concurrent Mode and Suspense to create an experience with a more fluid and app-like feel.

Thanks to this project, we’re more confident than ever that Concurrent Mode and Suspense can make it easier to deliver great, fast user experiences. But doing so requires rethinking how we approach loading code and data for our apps. Effectively all of the data-fetching on the new facebook.com is powered by Relay Hooks — new Hooks-based Relay APIs that integrate with Concurrent Mode and Suspense out of the box.

Relay Hooks — and GraphQL — won’t be for everyone, and that’s ok! Through our work on these APIs we’ve identified a set of more general patterns for using Suspense. Even if Relay isn’t the right fit for you, we think the key patterns we’ve introduced with Relay Hooks can be adapted to other frameworks.

Best Practices for Suspense

It’s tempting to focus only on the total startup time for an app — but it turns out that users’ perception of performance is determined by more than the absolute loading time. For example, when comparing two apps with the same absolute startup time, our research shows that users will generally perceive the one with fewer intermediate loading states and fewer layout changes as having loaded faster. Suspense is a powerful tool for carefully orchestrating an elegant loading sequence with a few, well-defined states that progressively reveal content. But improving perceived performance only goes so far — our apps still shouldn’t take forever to fetch all of their code, data, images, and other assets.

The traditional approach to loading data in React apps involves what we refer to as “fetch-on-render”. First we render a component with a spinner, then fetch data on mount (componentDidMount or useEffect), and finally update to render the resulting data. It’s certainly possible to use this pattern with Suspense: instead of initially rendering a placeholder itself, a component can “suspend” — indicate to React that it isn’t ready yet. This will tell React to find the nearest ancestor <Suspense fallback={<Placeholder/>}>, and render its fallback instead. If you watched earlier Suspense demos this example may feel familiar — it’s how we originally imagined using Suspense for data-fetching.

It turns out that this approach has some limitations. Consider a page that shows a social media post by a user, along with comments on that post. That might be structured as a <Post> component that renders both the post body and a <CommentList> to show the comments. Using the fetch-on-render approach described above to implement this could cause sequential round trips (sometimes referred to as a “waterfall”). First the data for the <Post> component would be fetched and then the data for <CommentList> would be fetched, increasing the time it takes to show the full page.

There’s also another often-overlooked downside to this approach. If <Post> eagerly requires (or imports) the <CommentList> component, our app will have to wait to show the post body while the code for the comments is downloading. We could lazily load <CommentList>, but then that would delay fetching comments data and increase the time to show the full page. How do we resolve this problem without compromising on the user experience?

Render As You Fetch

The fetch-on-render approach is widely used by React apps today and can certainly be used to create great apps. But can we do even better? Let’s step back and consider our goal.

In the above <Post> example, we’d ideally show the more important content — the post body — as early as possible, without negatively impacting the time to show the full page (including comments). Let’s consider the key constraints on any solution and look at how we can achieve them:

  • Showing the more important content (the post body) as early as possible means that we need to load the code and data for the view incrementally. We don’t want to block showing the post body on the code for <CommentList> being downloaded, for example.
  • At the same time we don’t want to increase the time to show the full page including comments. So we need to start loading the code and data for the comments as soon as possible, ideally in parallel with loading the post body.

This might sound difficult to achieve — but these constraints are actually incredibly helpful. They rule out a large number of approaches and spell out a solution for us. This brings us to the key patterns we’ve implemented in Relay Hooks, and that can be adapted to other data-fetching libraries. We’ll look at each one in turn and then see how they add up to achieve our goal of fast, delightful loading experiences:

  1. Parallel data and view trees
  2. Fetch in event handlers
  3. Load data incrementally
  4. Treat code like data

Parallel Data and View Trees

One of the most appealing things about the fetch-on-render pattern is that it colocates what data a component needs with how to render that data. This colocation is great — an example of how it makes sense to group code by concerns and not by technologies. All the issues we saw above were due to when we fetch data in this approach: upon rendering. We need to be able to fetch data before we’ve rendered the component. The only way to achieve that is by extracting the data dependencies into parallel data and view trees.

Here’s how that works in Relay Hooks. Continuing our example of a social media post with body and comments, here’s how we might define it with Relay Hooks:

// Post.js
function Post(props) {
  // Given a reference to some post - `props.post` - *what* data
  // do we need about that post?
  const postData = useFragment(graphql`
    fragment PostData on Post @refetchable(queryName: "PostQuery") {
      author
      title
      # ...  more fields ...
    }
  `, props.post);

  // Now that we have the data, how do we render it?
  return (
    <div>
      <h1>{postData.title}</h1>
      <h2>by {postData.author}</h2>
      {/* more fields  */}
    </div>
  );
}

Although the GraphQL is written within the component, Relay has a build step (Relay Compiler) that extracts these data-dependencies into separate files and aggregates the GraphQL for each view into a single query. So we get the benefit of colocating concerns, while at runtime having parallel data and view trees. Other frameworks could achieve a similar effect by allowing developers to define data-fetching logic in a sibling file (maybe Post.data.js), or perhaps integrate with a bundler to allow defining data dependencies with UI code and automatically extracting it, similar to Relay Compiler.

The key is that regardless of the technology we’re using to load our data — GraphQL, REST, etc — we can separate what data to load from how and when to actually load it. But once we do that, how and when do we fetch our data?

Fetch in Event Handlers

Imagine that we’re about to navigate from a list of a user’s posts to the page for a specific post. We’ll need to download the code for that page — Post.js — and also fetch its data.

Waiting until we render the component has problems as we saw above. The key is to start fetching code and data for a new view in the same event handler that triggers showing that view. We can either fetch the data within our router — if our router supports preloading data for routes — or in the click event on the link that triggered the navigation. It turns out that the React Router folks are already hard at work on building APIs to support preloading data for routes. But other routing frameworks can implement this idea too.

Conceptually, we want every route definition to include two things: what component to render and what data to preload, as a function of the route/url params. Here’s what such a route definition might look like. This example is loosely inspired by React Router’s route definitions and is primarily intended to demonstrate the concept, not a specific API:

// PostRoute.js (GraphQL version)

// Relay generated query for loading Post data
import PostQuery from './__generated__/PostQuery.graphql';

const PostRoute = {
  // a matching expression for which paths to handle
  path: '/post/:id',

  // what component to render for this route
  component: React.lazy(() => import('./Post')),

  // data to load for this route, as function of the route
  // parameters
  prepare: routeParams => {
    // Relay extracts queries from components, allowing us to reference
    // the data dependencies -- data tree -- from outside.
    const postData = preloadQuery(PostQuery, {
      postId: routeParams.id,
    });

    return { postData };
  },
};

export default PostRoute;

Given such a definition, a router can:

  • Match a URL to a route definition.
  • Call the prepare() function to start loading that route’s data. Note that prepare() is synchronous — we don’t wait for the data to be ready, since we want to start rendering more important parts of the view (like the post body) as quickly as possible.
  • Pass the preloaded data to the component. If the component is ready — the React.lazy dynamic import has completed — the component will render and try to access its data. If not, React.lazy will suspend until the code is ready.

This approach can be generalized to other data-fetching solutions. An app that uses REST might define a route like this:

// PostRoute.js (REST version)

// Manually written logic for loading the data for the component
import PostData from './Post.data';

const PostRoute = {
  // a matching expression for which paths to handle
  path: '/post/:id',

  // what component to render for this route
  component: React.lazy(() => import('./Post')),

  // data to load for this route, as function of the route
  // parameters
  prepare: routeParams => {
    const postData = preloadRestEndpoint(
      PostData.endpointUrl, 
      {
        postId: routeParams.id,
      },
    );
    return { postData };
  },
};

export default PostRoute;

This same approach can be employed not just for routing, but in other places where we show content lazily or based on user interaction. For example, a tab component could eagerly load the first tab’s code and data, and then use the same pattern as above to load the code and data for other tabs in the tab-change event handler. A component that displays a modal could preload the code and data for the modal in the click handler that triggers opening the modal, and so on.

Once we’ve implemented the ability to start loading code and data for a view independently, we have the option to go one step further. Consider a <Link to={path} /> component that links to a route. If the user hovers over that link, there’s a reasonable chance they’ll click it. And if they press the mouse down, there’s an even better chance that they’ll complete the click. If we can load code and data for a view after the user clicks, we can also start that work before they click, getting a head start on preparing the view.

Best of all, we can centralize that logic in a few key places — a router or core UI components — and get any performance benefits automatically throughout our app. Of course preloading isn’t always beneficial. It’s something an application would tune based on the user’s device or network speed to avoid eating up user’s data plans. But the pattern here makes it easier to centralize the implementation of preloading and the decision of whether to enable it or not.

Load Data Incrementally

The above patterns — parallel data/view trees and fetching in event handlers — let us start loading all the data for a view earlier. But we still want to be able to show more important parts of the view without waiting for all of our data. At Facebook we’ve implemented support for this in GraphQL and Relay in the form of some new GraphQL directives (annotations that affect how/when data is delivered, but not what data). These new directives, called @defer and @stream, allow us to retrieve data incrementally. For example, consider our <Post> component from above. We want to show the body without waiting for the comments to be ready. We can achieve this with @defer and <Suspense>:

// Post.js
function Post(props) {
  const postData = useFragment(graphql`
    fragment PostData on Post {
      author
      title

      # fetch data for the comments, but don't block on it being ready
      ...CommentList @defer
    }
  `, props.post);

  return (
    <div>
      <h1>{postData.title}</h1>
      <h2>by {postData.author}</h2>
      {/* @defer pairs naturally with <Suspense> to make the UI non-blocking too */}
      <Suspense fallback={<Spinner/>}>
        <CommentList post={postData} />
      </Suspense>
    </div>
  );
}

Here, our GraphQL server will stream back the results, first returning the author and title fields and then returning the comment data when it’s ready. We wrap <CommentList> in a <Suspense> boundary so that we can render the post body before <CommentList> and its data are ready. This same pattern can be applied to other frameworks as well. For example, apps that call a REST API might make parallel requests to fetch the body and comments data for a post to avoid blocking on all the data being ready.

Treat Code Like Data

But there’s one thing that’s still missing. We’ve shown how to preload data for a route — but what about code? The example above cheated a bit and used React.lazy. However, React.lazy is, as the name implies, lazy. It won’t start downloading code until the lazy component is actually rendered — it’s “fetch-on-render” for code!

To solve this, the React team is considering APIs that would allow bundle splitting and eager preloading for code as well. That would allow a user to pass some form of lazy component to a router, and for the router to trigger loading the code alongside its data as early as possible.

Putting It All Together

To recap, achieving a great loading experience means that we need to start loading code and data as early as possible, but without waiting for all of it to be ready. Parallel data and view trees allow us to load the data for a view in parallel with loading the view (code) itself. Fetching in an event handler means we can start loading data as early as possible, and even optimistically preload a view when we have enough confidence that a user will navigate to it. Loading data incrementally allows us to load important data earlier without delaying the fetching of less important data. And treating code as data — and preloading it with similar APIs — allows us to load it earlier too.

Using These Patterns

These patterns aren’t just ideas — we’ve implemented them in Relay Hooks and are using them in production throughout the new facebook.com (which is currently in beta testing). If you’re interested in using or learning more about these patterns, here are some resources:

  • The React Concurrent docs explore how to use Concurrent Mode and Suspense and go into more detail about many of these patterns. It’s a great resource to learn more about the APIs and use-cases they support.
  • The experimental release of Relay Hooks implements the patterns described here.
  • We’ve implemented two similar example apps that demonstrate these concepts:

    • The Relay Hooks example app uses GitHub’s public GraphQL API to implement a simple issue tracker app. It includes nested route support with code and data preloading. The code is fully commented — we encourage cloning the repo, running the app locally, and exploring how it works.
    • We also have a non-GraphQL version of the app that demonstrates how these concepts can be applied to other data-fetching libraries.

While the APIs around Concurrent Mode and Suspense are still experimental, we’re confident that the ideas in this post are proven by practice. However, we understand that Relay and GraphQL aren’t the right fit for everyone. That’s ok! We’re actively exploring how to generalize these patterns to approaches such as REST, and are exploring ideas for a more generic (ie non-GraphQL) API for composing a tree of data dependencies. In the meantime, we’re excited to see what new libraries will emerge that implement the patterns described in this post to make it easier to build great, fast user experiences.




pen

Electrosensitivity: 'I didn't believe people had it, then it happened to me'

Velma, Emma and Dean believe mobile phone signals, wi-fi and other modern technology makes them ill.




pen

Coronavirus: 'My cafe's going bust before it's even opened'

A car factory worker turned cafe owner explains how coronavirus is affecting his business dream.




pen

Al Ain 3-3 (4-3 pens) Team Wellington (UAE 2018)

A penalty shootout decided the opening match of the FIFA Club World Cup UAE 2018. Hosts Al Ain knocked out OFC champions Team Wellington thanks to the heroics of Al Ain goalkeeper Khalid Eisa.




pen

Esperance 1-1 (6-5 pens) CD Guadalajara (UAE 2018)

Nine-man Esperance ended their FIFA Club World Cup UAE 2018 campaign on a high after a tense 6-5 penalty shoot-out win against Chivas in the match for fifth place.