Giter Site home page Giter Site logo

pharolink's Introduction

PharoLink

PharoLink provides a mechanism for Pharo to communicate with remote Pharo processes.

Getting Started

Installation

PharoLink is already installed if you are using Gtoolkit.

Requirements:

PharoLink has been tested with Pharo 8 & 9.

To install PharoLink evaluate:

EpMonitor disableDuring: [ 
Metacello new
	repository: 'github://feenkcom/PharoLink:main/src';
	baseline: 'PharoLink';
	load ]

First statements

The playground examples pictured below assume you are running Gtoolkit. If you are running a vanilla Pharo image, the programmatic examples can be used.

Open a playground in Gtoolkit and start the PharoLinkApplication:

Start PharoLink

We can now evaluate our first expression in the remote server:

First Object

After typing the code in to the playground it is evaluated by pressing the play & inspect button:

Play & Inspect button

From here we can navigate through the attributes of the object in the same way as when inspecting pharo objects.

If the value of the attribute is a non-primitive object, a proxy will be returned, if it is a primitive, it will be returned directly:

Inspect Primitive

As well as inspecting the raw values of the remote object, any views which can be represented declaratively, or which have been explicitly specified by the remote object will also be displayed, e.g. the String, List and Columned List views shown below:

Declarative Views

When evaluating statements in a proxy object's playground, self is bound to the proxy object:

self bound

The remote server can then be stopped with:

PharoLinkApplication stop.

Programatic Use

So far we have been using a global instance of PharoLink, however it is also possible to have multiple servers running concurrently through the use of private instances.

PharoLink allows Pharo code to be supplied in two ways:

  1. Strings of code, and
  2. AST objects generated using RBParser

First, using strings:

"Start PharoLink"
pharolink := PharoLinkApplication withDefaultSettings.
pharolink start.

"Create an instance of the test inspectable and retrieve the string"
object := pharolink newCommandFactory
	<< 'GtDeclarativeTestInspectable new';
	sendAndWait.

date := object newCommandFactory
	<< 'self collectionOfObjects second';
	sendAndWait.

"Stop the server"
pharolink stop

Hello, World!

Second, using Smalltalk generated with RBParser:

"Start PharoLink"
pharolink := PharoLinkApplication withDefaultSettings.
pharolink start.

"Generate the expression and evaluate"
node := RBParser parseExpression: 
	'| inspectable hw |
	inspectable := GtDeclarativeTestInspectable new.
	hw := inspectable collectionOfObjects second.
	hw'.

date := pharolink newCommandFactory
	<< node;
	sendAndWait.

"Stop the server"
pharolink stop

Hello, World! with RBParser

Garbage Collection

Proxy objects register them selves for finalisation. When they are garbage collected in Pharo they are automatically removed from the registry in the node.js server.

Callbacks

Callbacks in to Pharo from the remote server are supported through observables.

See PharoLinkSendCommandTest for examples of setting up and using callbacks.

Automated Tests

See the 'PharoLink-Tests` package.

ToDo

PythonBridge supports communicating with the server using either HTTP or MsgPack. While the code has been left in the package, MsgPack is not yet supported.

Futures

TBS.

Acknowledgements and Thanks

Thanks to the team at ObjectProfile for making PythonBridge, on which PharoLink is based.

pharolink's People

Contributors

akgrant43 avatar chisandrei avatar maenu avatar svenvc avatar j-brant avatar syrel avatar georgeganea avatar girba avatar refactoringdr avatar hellerve avatar

Stargazers

Ralf Barkow avatar  avatar George Kontridze avatar Alin Iacob avatar Rafael Luque avatar Alexandre Bergel avatar

Watchers

 avatar  avatar Juraj Kubelka avatar James Cloos avatar Ronie Salgado avatar  avatar Ioana Verebi avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ralfbarkow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.