[squeak-dev] ANN: TiledMaps library - OpenStreetMaps, Bing Maps, Thunderforest maps and so on

Tony Garnock-Jones tonyg at leastfixedpoint.com
Tue Feb 13 18:04:03 UTC 2018


Hi Eliot,

On 02/13/2018 05:16 PM, Eliot Miranda wrote:
> would you be happy to see your video linked to, with prominent
> billing, from a suitable page on the squeak.org site?

Sure, that'd be cool!

> Also it would be great so see an article, perhaps a blog post, that
> shows how promises simplified the implementation and how promises are
> "merely" a piece of normal Smalltalk programming that did not require
> changing the language to integrate.
That's a good idea, too.

I don't know if "not changing the language" is very impressive, though?
Javascript's promises don't need language changes either; and
implementing Squeak-like promises for other languages would be similar.

But the heart of the change from "loading tiles blocks the UI and gets
incredibly annoying" to "smooth scrolling with lazy loading" was very
small, and that might be worth an article.

It was, at heart, this change: from

    ^ tileSource mapTileAt: point zoom: zoom

to

    | p |
    p := Promise new.
    [ p resolveWith: (tileSource mapTileAt: point zoom: zoom) ] fork.
    ^ p

plus adding

    self tilesDo: [:tile :formPromise |
      formPromise whenResolved: [ self changed ] ].

whenever the coordinates to be shown were changed, and using
`formPromise value` instead of `form` in `drawTilesOn:`, rendering a
loading tile when the promise wasn't ready yet.

The LRUCache then stored Promises, which were reused frequently until
the cache evicted them, instead of storing Forms directly.

Tony


More information about the Squeak-dev mailing list